How to replace double quotes with two single quotes in string in MATLAB (R2013a)?
12 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
MathWorks Support Team
am 25 Okt. 2013
Beantwortet: MathWorks Support Team
am 25 Okt. 2013
I have the following string which has double quotes. I would like to replace them with single quotes.
mystr = 'Hello "Joe" ';
Akzeptierte Antwort
MathWorks Support Team
am 25 Okt. 2013
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 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu String Parsing finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!