Possible Duplicate:
Replacing unquoted words only in Python
This is what I have right now
found = re.match( r"hello[(](.*)[)]", word, re.M|re.I)
It will find:
Hello(here) and give you "here"
I would like it to be able to do the following:
Hello (Hi)
return the value even if there is whitespace on either side (but only white space, not other characters), So this would return “Hi”
'dfsfds Hello (Hi) fdfd' Hello (Yes)
this would return “Yes” because the first part is enclosed by single quotes, so we don’t use that (the whitespace rule still applies here if possible)
EDIT:
Hello ('Hi') would return 'Hi'
It might not be perfect but this seems to satisfy your use cases. I feel that this is quite an involved process, and with a few more rules it would start to approach the types of problems that regexes are really bad at.