Regular expression

Paul Hemans paul.hemans at gmail.com
Fri Nov 5 21:25:52 EDT 2010


I need to extract the quoted text from :
_("get this")

The following works:
re.compile( "_\(['\"]([^'\"]+)['\"]\)" )
However, I don't want to match if there is A-Z or a-z or 0-9 or _ 
immediately preceding the "_" so I have tried:
"[^0-9a-zA-Z]*_\(['\"]([^'\"]+)['\"]\)"
"[^\w]{0,1}_\(['\"]([^'\"]+)['\"]\)"
"\W*_\(['\"]([^'\"]+)['\"]\)"

to match against:
skip this text _("get this")

Thanks 





More information about the Python-list mailing list