Reputation: 957
What is considered best practice, and what is the fastest to compute?
[A-Za-z]
vs.
[a-z]/i
Assuming that you don't care about the rest of the regex's case. I'm wanting to know with exactly those 2 regex's which is the fastest. Or does it yield the same outcome under the hood.
Upvotes: 2
Views: 1397
Reputation: 17888
A quick test on jsperf.com, shows that to search a single string from a-z
on a sample string would results that [a-zA-Z]
is slightly faster.
Here are the tests that I performed.
Upvotes: 3