Replace single quotation with single quotation and double quotation

49 Ansichten (letzte 30 Tage)
Banner Hulk
Banner Hulk am 5 Jun. 2020
Beantwortet: Image Analyst am 6 Jun. 2020
A = ‘Tom and Jerry’
B = ' "Tom and Jerry" '

Antworten (2)

David Hill
David Hill am 6 Jun. 2020
Bearbeitet: David Hill am 6 Jun. 2020
B=[char(34),A,char(34)];
B=['"',A,'"'];%or this as long as A is a character array

Image Analyst
Image Analyst am 6 Jun. 2020
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"

Kategorien

Mehr zu Characters and Strings finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by