[Python-3000] regex literals?

tomer filiba tomerfiliba at gmail.com
Tue Aug 29 21:43:57 CEST 2006

i can't say i'm too fond of this, but i thought of bringing this up. most
languages (perl, ruby, and boo, to name some) have regular expressions as
language literals. since such languages are heavily used for string
manipulation, it might seem like a good idea to add them at the syntax


i thought of prefixing "e" for "regular *e*xpression". could also be "p" for
it's very simple -- regex literal strings are just passed to re.compile(),
creation, i.e.:
a = e"[A-Z]"

is the same as
a = re.compile("[A-Z]")

what is it good for?

if e"[A-Z]".match("Q"):
    print "success"

since strings (as well as regex strings) are immutable, the compiler can
re.compile them at compile time, as an optimization.

again, i can't say i'like regex literals, and i don't think it would be a
productivity boost (although you would no longer need to import re and
re.compile() your patterns)... but i wanted to bring it to your

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/python-3000/attachments/20060829/f6a1c658/attachment.htm 

More information about the Python-3000 mailing list