Luis Parravicini
1/10/2007 11:02:00 AM
On 1/10/07, Manoj P M <manjo.pm@gmail.com> wrote:
> A Simple question on regular expression in ruby. Some can make me
> understand the below code snippets. I was under the impression that
> both these statement would give the same answer. But it doesnt. Why ?
>
> irb(main):001:0> 'banana' =~ /(an)*/
> => 0
In this case you are looking for '', 'an', 'anan', 'ananan' and so on.
So it matches at the beginning of the string (index 0) with the empty
string.
Luis