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

'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

Need Your Help

Python-iptables how to optimize code

python oop optimization iptables

I am just learning python and have written some code to set iptables using the python-iptables library. The problem I'm running in to is that I had to rewrite a lot of the same lines of code over and

NSBundle pathForResource failing in shell tool

objective-c cocoa macos

I've noticed some weird behavior with NSBundle when using it in a