It's not 100 % clear what exceptions you expect, but I presume you are trying to handle the case when the regex does not match. I suggest handling it this way:
#Transformation #1 match = re.match(pattern, inword) result = match.group() if match else None
A possible explanation to your program suddenly slowing down is that regexes can suffer from catastrophic backtracking.
Janne Karila
- 10.4k
- 20
- 34