What is the fastest way to check if a string matches a regular expression in Ruby?
My problem is that I have to \"egrep\" through a huge list of strings to find whic
What about re === str
(case compare)?
Since it evaluates to true or false and has no need for storing matches, returning match index and that stuff, I wonder if it would be an even faster way of matching than =~
.
Ok, I tested this. =~
is still faster, even if you have multiple capture groups, however it is faster than the other options.
BTW, what good is freeze
? I couldn't measure any performance boost from it.