The String class has the =~ method and the !~ operator. : match « String « Ruby
- Ruby
- String
- match
The String class has the =~ method and the !~ operator.
If =~ finds a match, it returns the offset position where the match starts in the string:
color = "color colour"
color =~ /colou?r/ # => 13
Related examples in the same category