On Fri, Aug 3, 2012 at 9:59 AM, Wayne Brisette <wbrisett / att.net> wrote:

> my_string.gsub!(/>/, "&lt;")
> my_string.gsub!(/</, "&gt;)
>
> which works, but I'm sure is horribly inefficient. Is there a better way to do
> multiple global substitutions on a string?

1.9.3p125 :001 > "<link>".gsub(/[<>]/,'<' => '&lt;', '>' => '&gt;')
 => "&lt;link&gt;"

There's a nice little example in the (cough) documentation...

-- 
Hassan Schroeder ------------------------ hassan.schroeder / gmail.com
http://about.me/hassanschroeder
twitter: @hassan