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!