re bug

Gustavo Niemeyer niemeyer at conectiva.com
Tue Oct 5 21:34:04 CEST 2004


> > That's not the same regular expression. You must escape whitespaces
> > when using re.VERBOSE.
> 
> As far as I can see, I did, except in character classes, and quoting
> from the 're' manual:

'''
(?P<ALLES>
   (?:
      [^/ ]*/[^/ ]*/
      (?:                 # why a group?
         cn
         (?: :[^/ #]+ )*
      )
       ^
There's one space here. Your version doesn't expose the issue
mentioned by the OP, as you may see by uncommenting the third
test case.

[...]
> I actually tried the example stated in 'man perlre', translated to
> python:
[...]
> but apparently there are ways to nest the backtracking without hitting
> recursion limits.

This is fixed in Python 2.4:

>>> import re
>>> r = re.compile("((a{0,5}){0,5})*[c]")
>>> r.match("a"*10)
>>>

-- 
Gustavo Niemeyer
http://niemeyer.net



More information about the Python-list mailing list