embedding executable code in a regular expression in Python
Avi Kak
kak at purdue.edu
Sun Jul 16 17:05:33 EDT 2006
Folks,
Does regular expression processing in Python allow for executable
code to be embedded inside a regular expression?
For example, in Perl the following two statements
$regex = qr/hello(?{print "saw hello\n"})mello(?{print "saw
mello\n"})/;
"jellohellomello" =~ /$regex/;
will produce the output
saw hello
saw mello
Is it possible to do the same in Python with any modules that come
with the standard distribution, or with any other modules?
Thanks in advance for any help,
Avi Kak (kak at purdue.edu)
More information about the Python-list
mailing list