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
'L''hopital''s rule'
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With