http://www.perlmonks.org?node_id=1090237


in reply to Re: Question about regex performance
in thread Question about regex performance

Thanks.

Define 'wrong', please. Is it wrong if it gives the right answer? Can you provide a test case that makes it fail? I do like test driven development since the tests define what is right or wrong (as long as they are carefully constructed, and defined by the functional requirements). My usual approach is to make the code right, first, as defined by the suite of unit and integration tests, and then make it fast (hence my search for alternate ways of doing the same thing). In some respects, though, regex_or is one I found, and it remains one I am not entirely sure I understand how or why it works. Regex are not my forte: I am more a quant, working with numeric methods: when working up regular expressions, I still have to have a reference for them open while I try to construct them.

I do like the approach you say you'd replace regex_or with, but that is one_liner. And that is still about 10% slower than both replace and double_plus, as is double_star. Do you have any thoughts as to why one_liner and double_star are about the same speed, why replace and double_plus are about the same speed, and why the first two are about 10% slower than the latter two? More importantly, is there a way to have code that verifies any conjecture as to why, or does such an explanation have to rest on arguments about how regex work?

Thanks again

Ted