MATLAB: How to replace double quotes with two single quotes in string in MATLAB (R2013a) MATLABregexprepstrrep I have the following string which has double quotes. I would like to replace them with single quotes. mystr = 'Hello "Joe" '; Best Answer 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 quotesnewStr1 = Hello 'Joe'>> newStr2 = strrep('Hello "Joe"','"','''''') % 6 single quotesnewStr2 = Hello 'Joe' Related SolutionsMATLAB: How to define string character It creates a string (character array) containing just a single space character. MATLAB: Replace several occurrence of one string with multiple different strings using regexprep without a for loop string = regexprep('2*sin(XXX)+XXX','XXX',{'ALPHA','BETA'},[1,2]) Related QuestionAdding quotes to stringMatlab single quote problemSaving with quotes.
Best Answer