A collection of code snippets which return a boolean value for a regex comparison.
regexp.match?(string) # Recommended for Ruby >= 2.4
!!(string =~ regexp) # Recommended for older Rubies
regexp === string
!(regexp !~ string)
The Ruby 2.4 method
Regexp#match?
Show archive.org snapshot
does not set globals like $~
or $1
, so it should be more performant.
Posted by Emanuel to makandra dev (2017-02-09 13:29)