Replace single quotation with single quotation and double quotation

답변 (2개)

David Hill
David Hill 2020년 6월 6일
편집: David Hill 2020년 6월 6일
B=[char(34),A,char(34)];
B=['"',A,'"'];%or this as long as A is a character array
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 Exchange에서 Dates 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