From: Paul Lutus Date: 2006-11-19T12:20:05+09:00 Subject: Re: How to use regexp to replace character with backslash plus this character William James wrote: / ... > irb(main):055:0> puts ";!&%$".gsub( /[;!&%$]/, '\\\\\&' ) > \;\!\&\%\$ > > irb(main):008:0> puts ";!&%$".gsub( /[;!&%$]/ ){ "\\" + $& } > \;\!\&\%\$ > > irb(main):009:0> puts ";!&%$".gsub( /[;!&%$]/ ){ "\\#{ $& }" } > \;\!\&\%\$ > > irb(main):011:0> puts ";!&%$".gsub( /([;!&%$])/ ){ "\\#{ $1 }" } > \;\!\&\%\$ Yes, except that I hate using those Perlish globals. Just a personal thing. -- Paul Lutus http://www.arachnoid.com