Message16369
Logged In: YES
user_id=589306
If you change your regex and sample data to the following
simpler forms, you get the same problem:
pattern = '(\S+\s*)+,'
str = 'CAST(EXTRACT(EPOCH FROM CURRENT_TIMESTAMP)'
If you remove some letters from str, the search does finish
but it takes several seconds. I believe the problem is that
your regex takes exponential time to execute based on the
length of str. Here is a recent python-dev post that talks
about the problem:
http://mail.python.org/pipermail/python-dev/2003-May/035916.html
The link you provided in the bug report talks about this as
well. You can also do a web search for "regular expression
exponential" to see more information. I believe that any
regex engine (that has similar features to Python's engine)
will have some regular expressions that take exponential
time or space. Perl has some cases as well (search for
"exponential" in perldoc perlre). This is just how regular
expressions are and IMHO does not indicate a bug in Python.
As far as how to fix the regular expression, I can't say.
I'm sure there is a way to "rephrase" what you want to get
it to work. Maybe try asking in the comp.lang.python newsgroup.
Good luck!
|
|
Date |
User |
Action |
Args |
2007-08-23 14:13:52 | admin | link | issue753711 messages |
2007-08-23 14:13:52 | admin | create | |
|