From: Nobuyoshi Nakada Date: 2006-11-24T18:55:03+09:00 Subject: Re: double-slashes in input causing trouble Hi, At Fri, 24 Nov 2006 01:39:05 +0900, Jeremy Wells wrote in [ruby-talk:226339]: > if body =~ /^section\sheader(.*)section\sfooter/mi > original_section = $1 > new_section = bit_at_top + original_section > new_body = body.sub(original_section, new_section) You can use bang-version to replace and tell if it is done, at once. if body.sub!(/^(section\sheader)(.*section\sfooter)/mi) {$1+bit_at_top+$2} > File.open(input,'w') do |file| file.write body > end > end -- Nobu Nakada