Jul 22, 2013, 10:14 AM
The .* in the first regex tells it to skip over all of the chars and go to the end of the string and then backtrack one char at a time to try and match the pattern at the end.
Re: [anglaissam] Regex benchmark
The second regex first needs to check each char in the string to see if it's a '.' then once that is matched, it checks for each of the next chars one-by-one.
The difference in speed of match becomes greater as the length of the string increases.
The alternation used in each regex is unnecessary and adds inefficiency.
This would be better than the alternation.
It would be interesting to benchmark the regex against using index.
(This post was edited by FishMonger on Jul 22, 2013, 10:15 AM)