regular expressions questions

Neel Krishnaswami neelk at brick.cswv.com
Wed Mar 29 02:29:20 CEST 2000


Andrew M. Kuchling <akuchlin at mems-exchange.org> wrote:
> Derek Thomson <derek at ooc.com.au> writes:
> >
> > I'm sure a decent syntax could be devised with a little
> > thought. After all, the named subexpression idea is very good, and
> > a great improvement over Perl's numbering system ie $1, $2 etc.
> 
> Suggestions would be welcomed, and could rescue the idea from
> oblivion.  Feel free to post a proposed syntax; we can then refine it
> through further discussion.

I think that Greg Ewing has the right idea with Plex; strings should
be for strings, not for encoding a regular expression in. We have a
perfectly good language -- Python -- for expressing data structures
in. Trying to encode regexps in a seperate sublanguage will just grow
escape sequences without bound, because the set of characters that can
be part of a string overlaps with the characters that denote regexp
info. 

  x = Str("[foo]", "(bar)")

is simpler than the crazy nest of quoting that is

  x = re.compile(r"(\[foo\])|(\(bar\))")

and it gets relatively simpler as the complexity of the regexp goes
up.


Neel



More information about the Python-list mailing list