How to replace double quotes with two single quotes in string in MATLAB (R2013a)?
조회 수: 12 (최근 30일)
이전 댓글 표시
MathWorks Support Team
2013년 10월 25일
답변: MathWorks Support Team
2013년 10월 25일
I have the following string which has double quotes. I would like to replace them with single quotes.
mystr = 'Hello "Joe" ';
채택된 답변
MathWorks Support Team
2013년 10월 25일
Here is an example using both REGEXPREP and STRREP to replace double quotes with two single quotes:
>> mystr = 'Hello "Jonathan" ';
>> newStr1 = regexprep('Hello "Joe"','"','\''''') % single quote, backslash, 5 single quotes
newStr1 =
Hello 'Joe'
>> newStr2 = strrep('Hello "Joe"','"','''''') % 6 single quotes
newStr2 =
Hello 'Joe'
댓글 수: 0
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 String Parsing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!