Replace single quotation with single quotation and double quotation

回答 (2 件)

David Hill
David Hill 2020 年 6 月 6 日
編集済み: David Hill 2020 年 6 月 6 日

0 投票

B=[char(34),A,char(34)];
B=['"',A,'"'];%or this as long as A is a character array
Image Analyst
Image Analyst 2020 年 6 月 6 日

0 投票

Some options, depending on what you want:
A = 'Tom and Jerry' % Input
B = '"Tom and Jerry"' % Desired output
% Try one of these.
B1 = sprintf('"%s"', A)
B2 = string(A)
You'll see
A =
'Tom and Jerry'
B =
'"Tom and Jerry"'
B1 =
'"Tom and Jerry"'
B2 =
"Tom and Jerry"

カテゴリ

ヘルプ センター および File ExchangeDates and Time についてさらに検索

タグ

質問済み:

2020 年 6 月 5 日

回答済み:

2020 年 6 月 6 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by