Why the regexp does not work?

Here is the Ruby code (ruby 2.2.3p173 (2015-08-18 revision 51636)
[x64-mingw32]):
/--------------------------------------------------------------/
#Begin of code
str = “str1 str2 str3 str4”
str.scan(/(\b(str3)|(str1)\B)|(\b(str4)|(str2)\B)/).each {|elm| puts
elm.to_s}
#End of code
/-----------RESULTS--------------------------------------------/
#Expected:
#=> [“str1”, nil, “str1”, nil, nil, nil]
#=> [nil, nil, nil, “str2”, nil, “str2”]
#=> [“str3”, “str3”, nil, nil, nil, nil]
#=> [nil, nil, nil, “str4”, “str4”, nil]
/--------------------------------------------------------------/
#In fact:
#=> [“str3”, “str3”, nil, nil, nil, nil]
#=> [nil, nil, nil, “str4”, “str4”, nil]
/--------------------------------------------------------------/

You can see, that the last regexp groups (brackets):
(str1) in (\b(str3)|(str1)\B)
and
(str2) in (\b(str4)|(str2)\B)

do not work.

Please advise.
TIA!
Vad

It does work like this:

#Begin of code
str = “str1 str2 str3 str4”
str.scan(/(\b(str3)|(str1)\b)|(\b(str4)|(str2)\b)/).each {|elm| puts
elm.to_s}
#End of code