Making regex suck less
Fredrik Lundh
fredrik at pythonware.com
Thu Sep 5 02:41:14 EDT 2002
Bengt Richter wrote:
> >you can ask SRE to dump the internal parse tree
> >to stdout:
> >
> >>>> sre.compile("[a-z]\d*", sre.DEBUG)
> >in
> > range (97, 122)
> >max_repeat 0 65535
> > in
> > category category_digit
> >
> >turning this into 'English' is left as an exercise etc.
>
> Interesting, thanks. Does the above mean that sre can't fully match
> 'a'+'9'*65537
> ?
in this context, 65535 represents any number:
>>> import re
>>> p = re.compile("[a-z]\d*")
>>> s = "a"+"9"*65537
>>> len(s)
65538
>>> m = p.match(s)
>>> len(m.group(0))
65538
</F>
More information about the Python-list
mailing list