Deleting everything that is enclosed with quotes or is a number in Python?
Question: 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.


Answer: 
    Python 2.7.2 (default, Aug 19 2011, 20:41:43) [GCC] on linux2
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import re
    >>> re.sub(r"('[^']*'|\d)", "", "'Hello'+yes+'Whats hello'6")
    '+yes+'
    >>>
    

`(...|...)` matches one thing or another; `'[^']*'` matches anything but a
quote inside quotes; `\d` matches 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?

    
    
    >>> import re
    >>> re.sub(r"('[^']*'|(?<![a-zA-Z])\d(?![a-zA-Z]))", "", "'Hello'+yes+'Whats hello'6")
    '+yes+'
    >>> re.sub(r"('[^']*'|(?<![a-zA-Z])\d(?![a-zA-Z]))", "", "+ye5s")
    '+ye5s'
    

