From: Peter Date: 2003-12-18T04:29:08+09:00 Subject: Re: gsub question > ruby -e 'a="hello hi hello";a.gsub!(/(\w+)/,"#{$1}a"); puts a' > a a a > > Why? I'm expecting the same result as in perl. $1 is evaluated before the matching happens, and since you didn't match anything yet, $1 is the empty string. Do this instead: ruby -e 'a="hello hi hello";a.gsub!(/(\w+)/,"\\1a"); puts a' helloa hia helloa Peter