[Python-3000] regex literals?

Guido van Rossum guido at python.org
Tue Aug 29 21:46:09 CEST 2006

Do I even have to say -1?

Regular expressions shouldn't become the front and central of Python's
text processing tools.


On 8/29/06, tomer filiba <tomerfiliba at gmail.com> wrote:
> i can't say i'm too fond of this, but i thought of bringing this up. most
> scripting
> 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
> level:
> e"[A-Za-z_][A-Za-z_0-9]*"
> i thought of prefixing "e" for "regular *e*xpression". could also be "p" for
> pattern.
> it's very simple -- regex literal strings are just passed to re.compile(),
> upon
> 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
> consideration.
> -tomer
> _______________________________________________
> Python-3000 mailing list
> Python-3000 at python.org
> http://mail.python.org/mailman/listinfo/python-3000
> Unsubscribe:
> http://mail.python.org/mailman/options/python-3000/guido%40python.org

--Guido van Rossum (home page: http://www.python.org/~guido/)

More information about the Python-3000 mailing list