From: Sebastian Hungerecker Date: 2008-05-26T17:49:20+09:00 Subject: Re: regular expression question... hongseok.yoon@gmail.com wrote: > file = open("source.txt", "r") > file.each_line {|line| >    if line.match /(.*)\/\// >       puts $1 if $1.length > 0 >    end > } > file.close > > result is... > > 12 >   / > 12/ > > but!, what I expected is~ > > 12 > 12 .* tries to match as much as possible (greedy) so the \/\/ will match the last // it finds - not the first. If you want to make the .* non-greedy, add a ? after the *. HTH, Sebastian -- Jabber: sepp2k@jabber.org ICQ: 205544826