Is there any way to decompile a regular expression once compiled?
+15
A:
Compiled regular expression objects have a "pattern" attribute which gives the original text pattern.
>>> import re
>>> regex = re.compile('foo (?:bar)*')
>>> regex.pattern
'foo (?:bar)*'
dcrosta
2009-09-22 15:11:31
Wow great, why can't I see it if I do a dir(regex) ?? I tried to introspect but cannot find where this property comes from...
nabucosound
2009-09-22 16:14:46