From: Greg Hurrell Date: 2007-02-15T03:40:06+09:00 Subject: Re: Programmatically turning a Regexp into an anchored Regexp On 14 feb, 19:06, Wolfgang N�dasi-Donner wrote: > > irb(main):004:0> "foo at the beginning".gsub(/^#{r1}/, '###') > => "### at the beginning" > irb(main):005:0> "the foo in the middle".gsub(/^#{r1}/, '###') > => "the foo in the middle" Thanks, Wolfgang. I had no idea that #{} could be used not only to interpolate within literal Strings, but within Regexps as well. I now see that it's noted on page 66 of The Pickaxe... "In addition, a regular expression may contain #{...} expression substitutions." I tried it out and I see that it also works even if the original Regexp already has a "^" in it... Cheers, Greg