From: "David A. Black" Date: 2005-04-28T19:21:56+09:00 Subject: Re: Scanning a String Hi -- On Thu, 28 Apr 2005, Robert Klemme wrote: > > "Nicholas Seckar" schrieb im Newsbeitrag > news:6bfb9c8a050427193967475977@mail.gmail.com... >> On 4/27/05, David A. Black wrote: >>> (You don't really need the block arg (match) :-) >> >> Good point :-) >> >>> pious".gsub(/([aeiou])(?=[aeiou])/) { "#{$1}'#{$2}" } >> >> We could also do away with the block altogether and use >> "pious".gsub(/([aeiou])(?=[aeiou])/, '\1\'\2') >> >> Although I don't know if one approach is preferred to the other. > > Yes, it's preferred because it's faster. Although your variant works, I > usually prefer to put the correct number of backslashes in there: > > "pious".gsub(/([aeiou])(?=[aeiou])/, '\\1\'\\2') Why do you consider that more correct? David -- David A. Black dblack@wobblini.net