From: Chris Meyers Date: 2006-10-17T02:29:54+09:00 Subject: Re: Ruby Regexp vs Perl and C# Verno Miller wrote: > > It's a bit tricky but still doable! > > line = "banana" > > If your goal is to match just (an)* in "banana" use: > > line.scan(/((an)*)/) { |str| > #puts $1.inspect > puts $1 if $1 != "" > } Thank you Verno, that is what I needed. By using the block syntax I am able to get the same output as Perl or C# and I can adapt that to my problem at hand. For anyone interested, to recreate the same output in Ruby as my Perl and C# example the following code works: line="banana" line.scan(/(an)*/) { puts $` + "<<" + $& + ">>" + $' + "\n" } Thanks again, Chris -- Posted via http://www.ruby-forum.com/.