Firstly, I wrote something like this: patn = r"\bROW\s*\((\d+|\*)\)(.
\s)*?\)" newlines = re.sub(patn, "\nYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY\n", newlines) but if the file(or string) ended without the expected ")" the code deadlock there, no progress, no exception, and no exit. Then I changed it to : patn = r"\bROW\s*\((\d+
Min, you need to give a complete example other people can actually run for themselves. Offhand, this part of the regexp (.|\s)* all by itself _can_ cause exponential-time behavior. You can run this for yourself: >>> import re >>> p = r"(.
\s)*K" >>> re.search(p, " " * 10) # fast >>> re.search(p, " " * 15) # fast >>> re.search(p, " " * 20) # obviously takes a bit of time >>> re.search(p, " " * 21) # very obviously takes time >>> re.search(p, " " * 22) # over a second >>> re.search(p, " " * 25) # about 10 seconds Etc.
Closing as not-a-bug - not enough info to reproduce, but the regexp looked prone to exponential-time backtracking to both MRAB and me, and there's been no response to requests for more info.
History
Date
User
Action
Args
2022-04-11 14:59:00
admin
set
github: 77747
2018-07-29 00🔞40
tim.peters
set
status: open -> closedcomponents: + Regular Expressionsnosy: + ezio.melottimessages: + resolution: not a bugstage: resolved