From: Roberto Rivera Date: 2007-04-28T07:19:58+09:00 Subject: Re: String substitution? Robert Dober wrote: > On 4/27/07, Roberto Rivera wrote: >> >> "hello".gsub(/[aeiou]/, '*') #=> "h*ll*" >> >> In my particular case, I need it to match the whole string for >> substitution. >> >> I worked out this code in order to substitute '\"' for '"' and '\\' for >> '\': >> >> <%= text.split('\"').join('"').split("\\\\").join("\\") %> > First of all there is nothing wrong with this(1), I like it a lot, > however as you have asked;) > > text.gsub('\"','"').gsub("\\\\","\\") > > might indeed be considered a little bit more concise. > > Funny how this pattern just matches my previous post in the string > replacement thread. > > HTH > Robert > (1) With the exception of a trailing \" or \\" Indeed, I was trying to get a more concise alternative. Yours is perfect. Thanks -- Posted via http://www.ruby-forum.com/.