3 ms·
Go uses a different regex algorithm that doesn't fall over in corner cases. See: http://swtch.com/~rsc/regexp/regexp1.html http://swtch.com/~rsc/regexp/regexp1
by kyrra 12y ago
Go uses a different regex algorithm that doesn't fall over in corner cases. See:
http://swtch.com/~rsc/regexp/regexp1.html http://swtch.com/~rsc/regexp/regexp1.html
And Russ's comment here: https://groups.google.com/forum/m/#!topic/golang-nuts/6d1maef4jQ8 https://groups.google.com/forum/m/#!topic/golang-nuts/6d1mae...
EDIT: I shouldn't answer question I don't know the full answer to.
- comex 12y agoThe comment does not accurately reflect the state of the benchmarks today. (I do not know whether it accurately reflects the state of the benchmarks at the time of posting.) While some of the implementations are backtracking, the #2 slot is currently held by a C++ implementation that uses RE2: https://code.google.com/p/re2/ https://code.google.com/p/re2/ which also provides the linear guarantee. Edit: Apparently I forgot that RE2 was also written by Russ Cox, so he should know well that it provides better performance with the same guarantee.