raise NoSuchStrategyError unless some_string1[1] + some_string2[1] =~ /[RSP]{2}/i
I do not get the “=~ /[RSP]{2}/i” part.
If you guys have time to answer, I’d appreciate the help.
I mean what does =~ do in there?
What does “/ /i” do in there?
I have a guess that /[RSP]{2}/i produces all possible pairs out of [RSP]. Is that true? Why do we need / /i then? Why doesn’t it produce pairs in irb, when I type /[RSP]{2}/i all I get from irb is
=> /[RSP]{2}/i
and not pairs.
It’s a shortcut for regex (regular expression) match. It does not produce any pairs.
=~operator means “does left-hand value match right-hand regex?”/[RSP]{2}/is a regex literal. You can write it instead ofRegex.new("[RSP]{2}")And, finally, trailing
/iin regex literal means that this regex should be case-insensitive.