Why doesn't this regexp match all the b
s in the string?
'abbbbbbb'.match(/b*/)
#=> #<MatchData "">
whereas this does:
'abbbbbbb'.match(/b+/)
#=> #<MatchData "bbbbbbb">
- The definition of
*
is: "The asterisk indicates there is zero or more of the preceding element". - The definition of
+
is: "The plus sign indicates there is one or more of the preceding element".
The only difference between the two operators then is the number of matches that they make. They should both match 7 b
s.