From: Wes Gamble Date: 2006-08-03T08:40:10+09:00 Subject: Re: Using gsub to remove embedded newlines in HTML file Wes Gamble wrote: > Something like: > > @html.scan(/~\^LNK:.*?\^~/mi).each do |link_line| > new_link_line = link_line.gsub(/[\s\r\n]/, '') > @html.gsub!(/#{link_line}/mi, new_link_line) > end This seems to work well: @html.scan(/~\^LNK:.*?\^~/mi).each do |link_line| new_link_line = link_line.gsub(/[\t\r\n]/, '') @html.gsub!(/#{Regexp.escape(link_line)}/mi, new_link_line) if link_line != new_link_line end I wonder if I could have done with with one @html.gsub!() command, but this is much more understandable to me anyway so I'll stick with this. Thanks, Wes -- Posted via http://www.ruby-forum.com/.