Sprintf Matlab with Apostrophe
I have a string listed below with apostrophe.
stringVar = '''L''hopital''s rule'''
when I do sprintf i.e. sprintf(stringVar) it prints this 'L'hopital's rule'.
Now, what I would like to do is do an sprintf so that when I print it it will display as
Now I know I can easily do this '''L''''hopital''''s rule''' but would prefer to do it programatically. What's the best/correct way of approaching this problem. Note: I will need to handle many of these e.g. '''L''Environment'''.
ind = regexp(stringVar, '\w''\w') + 1; %// detect quotes between word characters stringVarRep = stringVar(sort([1:numel(stringVar) ind])); %// repeat those quotes