On Thu, 09 Apr 2009 02:56:00 -0700, David Liang wrote: > Hi all, > I'm having a weird problem with a regular expression (tested in 2.6 and > 3.0): > > Basically, any of these: > _re_comments = re.compile(r'^(([^\\]+|\\.|"([^"\\]+|\\.)*")*)#.*$') > _re_comments = re.compile(r'^(([^#]+|\\.|"([^"\\]+|\\.)*")*)#.*$') > _re_comments = re.compile(r'^(([^"]+|\\.|"([^"\\]+|\\.)*")*)#.*$') > > followed by for example, > line = r'~/.[m]ozilla/firefox/*.default/chrome' > print(_re_comments.sub(r'\1', line)) > > ...hangs the interpreter.
I can confirm the first one hangs the interpreter in Python 2.5 as well. I haven't tested the other two. To my mind, this is a bug in the RE engine. Is there any reason to not treat it as a bug? -- Steven -- http://mail.python.org/mailman/listinfo/python-list