Why does Ruby have 4 different regexp match functions?
Regexp#match?: 2630002.5 i/s Regexp#===: 872217.5 i/s - 3.02x slower Regexp#=~: 859713.0 i/s - 3.06x slower Regexp#match: 539361.3 i/s - 4.88x slower
match returns match data, and sets the $~ variable
=== returns true or false, setting the $~ variable
=~ returns integer (position) or nil, setting $~
The newest one match? returns a boolean, not setting $~
Why does Ruby have 4 different regexp match functions?
Regexp#match?: 2630002.5 i/s Regexp#===: 872217.5 i/s - 3.02x slower Regexp#=~: 859713.0 i/s - 3.06x slower Regexp#match: 539361.3 i/s - 4.88x slower