From: William James Date: 2006-07-29T09:50:12+09:00 Subject: Re: Finding "\" in a string Eric Armstrong wrote: > Paul Battley wrote: > > On 29/07/06, William James wrote: > >> >> puts "\\foo\\bar".gsub(/\\/, '\&\&' ) > >> \\foo\\bar > > > > Nice solution. > > > I'll say! Wild! What makes /that/ work??? \& is simply what was matched by the regex. It's similar in awk: BEGIN { s = " foo " sub(/[^ ]+/, "&&&", s) print s } ===> foofoofoo