I have a regex:
import re
regexp = re.compile(r'^(?P<parts>(?:[\w-]+/?)+)/$')
It matches the type string foo/bar/baz/and puts it foo/bar/bazin a group with a name parts( /?in combination with support /$).
This works fine until you compare a string that does not end with a dash . Then it becomes slower at an apparent exponential speed with each new char that you add to the corresponding line.
Example
regexp.match('this-will-take-no-time-at-all/')
regexp.match('this-takes-about-5-seconds')
regexp.match('this-probably-will-not-finish-until-the-day-star-turns-black')
, , /$ ( ) (.. ). , , ?
. .