Bugs item #1721518, was opened at 2007-05-18 20:12
Message generated for change (Comment added) made by goatchurch
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1721518&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Regular Expressions
Group: Python 2.4
Status: Open
Resolution: None
Priority: 4
Private: No
Submitted By: Julian Todd (goatchurch)
Assigned to: Gustavo Niemeyer (niemeyer)
Summary: Small case which hangs

Initial Comment:
import re
s = "Add.1, 2020 and Add.1, 2021-2023, 2025, 2028 and 2029 and Add.1) R"
r = "(?:\s|,|and|Add\S*?|Parts?|\([^\)]*\)|[IV\-\d]+)*$"
print "It's going to crash"
print re.search(r, s)
print "It hasn't crashed"

----------------------------------------------------------------------

>Comment By: Julian Todd (goatchurch)
Date: 2007-05-18 22:37

Message:
Logged In: YES 
user_id=301384
Originator: YES

I can shorten it further to: 

s = "Add.1, 2020 Add.1, 20212023, 2025, 2028 and 2029 Add.1) R"
r = "(?:\s|,|and|Add\S*?|[\d]+)*$"

Sometimes it finishes after a long time when you shorten the s-string from
the front.  If you take the "R" from the end it goes through straight away.
 It's even very slow with match.  

----------------------------------------------------------------------

Comment By: Georg Brandl (gbrandl)
Date: 2007-05-18 20:55

Message:
Logged In: YES 
user_id=849994
Originator: NO

I assume this is one of the pathological cases where the RE algorithm
backtracks "to death". That's not really a bug, but a limitation.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1721518&group_id=5470
_______________________________________________
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to