From: Brian Adkins Date: 2007-06-21T23:45:15+09:00 Subject: Re: Do You Understand Regular Expressions? On Jun 21, 4:43 am, Wild Karl-Heinz wrote: > Hello Ryan > > In message "Do You Understand Regular Expressions?" > on 21.06.2007, Ryan Mcdonald writes: > > RM> I agree. Can someone explain why gsub, sub or scan matches with * are > RM> different than =~ matches with * > > RM> puts "hello".gsub(/[aeiou]/, '<\1>') # h<>ll<> > > irb(main):024:0> "hello".gsub( /([aeiou])/, "<\\1>" ) > > Please note the () around the expression. > After that you can refer with \\1 to the found > letters. Why not simply change the 1 to a 0 ? irb(main):001:0> puts "hello".gsub(/[aeiou]/, '<\0>') hll