Why is a character class faster than alternation?
问题 It seems that using a character class is faster than the alternation in an example like: [abc] vs (a|b|c) I have heard about it being recommended and with a simple test using Time::HiRes I verified it (~10 times slower). Also using (?:a|b|c) in case the capturing parenthesis makes a difference does not change the result. But I can not understand why. I think it is because of backtracking but the way I see it at each position there are 3 character comparison so I am not sure how backtracking