Lets say I have this string:
myString="'Hello'+yes+'Whats hello'6"
I am looking for a way to delete everything enclosed in quotes
So, it would become:
"+yes+"
Because, ‘Hello’ and ‘Whats hello’ are enclosed by quotes. And 6 is a number.
Is there a way to do this? Maybe using Regular Expressions? I tried doing this with a For Loop, but I guess my logic wasn’t that great.
(...|...)matches one thing or another;'[^']*'matches anything but a quote inside quotes;\dmatches digits.re.sub(pattern, replacement, string)replaces each instance of pattern with the replacement.ps note that the
'in the result are just python putting quotes around the string! (you can use single or double quotes in python; python prefers single when printing strings, if the string itself doesn’t contain any).update – is this what you want?