Reputation: 753
Following regex comparison is taking too long (> 2 mins).
re.search('^(\S+){2,50}/(\S+){2,50}\-trailing/$', 'test-request/this-is-crashing/')
Removing the length limits ({2-50}), solves the issue.
What is the error in the pattern?
env: Ubuntu i5 4GB Python 2.7.3
Upvotes: 0
Views: 328
Reputation: 43447
why not make it much simpler...
re.match('([^/]+)/([^/]+)-trailing/', 'test-request/this-is-crashing/')
although in this case it does not find anything...
i suppose you want to catch only strings which are similar to this:
'<SOME-TEXT>/<SOME-TEXT>-trailing/'
Upvotes: 0
Reputation: 59604
(\S+){2,50}
Are you sure you need this? \S+
means one or more occurrences. And then you want 2-50 occurrences of it?
Why not:
\S{2,50}
Upvotes: 8