-1

I wonder which regular expression algorithm does Python's re module use~

2

1 Answer 1

5

(I would comment but I can't at the moment)

If you read the article you linked thoroughly, it says that Python uses a backtracking algorithm.

In contrast, Perl, PCRE, Python, Ruby, Java, and many other languages have regular expression implementations based on recursive backtracking that are simple but can be excruciatingly slow.

Of course, every language would implement regex differently, though the time complexity should be similar. If you want to investigate how exactly it's done, you can simply just read the algorithms.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.