Regular Expressions, Speed, Python, and NFA

Peter Otten __peter__ at web.de
Fri Apr 14 12:39:25 EDT 2017


Malik Rumi wrote:

> I am running some tests using the site regex101 to figure out the correct
> regexs to use for a project. I was surprised at how slow it was,
> constantly needing to increase the timeouts. I went Googling for a reason,
> and solution, and found Russ Cox’s article from 2007:
> https://swtch.com/~rsc/regexp/regexp1.html . I couldn’t understand why, if
> this was even remotely correct, we don’t use NFA in Python, which led me
> here:

You might try

https://en.wikipedia.org/wiki/RE2_(software)

for which Python wrappers are available. However, 

"RE2 does not support back-references, which cannot be implemented 
efficiently."



More information about the Python-list mailing list