A Sublime package I'm using for autocompletion in lua uses Python's 're' module, but one regex is causing major slowdowns. Here's a minimal example:
import re
rx = re.compile(r"\bfunction(?:\s+[a-zA-Z0-9._]*)?\(((?:[a-zA-Z_][a-zA-Z0-9_]*|\.\.\.|,\s*)*)\)")
rx.match('function f(aaaaaaa, bbbbbbbb, cccccccc, ddddddd eeeeee)') # Very slow
rx.match('function f(aaaaaaa, bbbbbbbb, cccccccc, ddddddd, eeeeee)') # Adding a comma between the last function arguments in the string fixes it.
I'm out of my depth with regex debugging, but this seems relevant, though it's over my head.
Does anyone know an equivalent pattern I can use, but which has good performance?
Thank you!