Topic: Problem in regular expression

Hi everyone,

I am new to Ruby and got struck in regular expressions. It may be not a big problem but i am not able to understand this:

Consider the following code:

1. for i in 1..100
2.   print "Now at #{i}. Restart?"
3.   retry if gets =~ /^y/i #here
4. end

Can anyone tell me what does 'i'(/^y/i) in line 3 means??

Thanks

Re: Problem in regular expression

it means to ignore case sensitivity. That regular expression will match "Y" as well as "y"

Re: Problem in regular expression

tortoise wrote:

it means to ignore case sensitivity. That regular expression will match "Y" as well as "y"

Actually it will match anything that starts with y or Y (hence the ^ at the beginning of the expression). So you can type "yes" or "Yes" or "YOOOOOOOOOOOOOOOO" and it would all work tongue

vinnie - rails forum admin

Re: Problem in regular expression

Thanks Vin and Matt