I saw this on a screencast and couldn\'t figure out what it was. Reference sheets just pile it in with other operators as a general pattern match operator.
As the other answers already stated, =~ is the regular expression vs string match operator.
Note: The =~ operator is not commutative
Please consider the note below from the ruby doc site, as I have seen yet only the first form
str =~ regexp
used in the other answers:
Note:
str =~ regexpis not the same asregexp =~ str. Strings captured from named capture groups are assigned to local variables only in the second case.
Here is the documentation for the second form: link