Ruby Regexp: + vs *. special behaviour?
- by seb
Using ruby regexp I get the following results:
>> 'foobar'[/o+/]
=> "oo"
>> 'foobar'[/o*/]
=> ""
But:
>> 'foobar'[/fo+/]
=> "foo"
>> 'foobar'[/fo*/]
=> "foo"
The documentation says:
*: zero or more repetitions of the preceding
+: one or more repetitions of the preceding
So i expect that 'foobar'[/o*/] returns the same result as 'foobar'[/o+/]
Does anybody have an explanation for that