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
Depending on how complicated your regular expression is, you could possibly just use simple string slicing. I'm not sure about the practicality of this for your application or whether or not it would actually offer any speed improvements.
'testsentence'['stsen']
=> 'stsen' # evaluates to true
'testsentence'['koala']
=> nil # evaluates to false