From: Jeremy Wells Date: 2006-11-24T01:39:05+09:00 Subject: double-slashes in input causing trouble I'm writing a ruby program that reads a file, reads sections out of that file, writes a header to each section and then writes the whole file back to disk. The problem is that if the section contains "\\" which mine does in places, ruby replaces these with a single "\" without my asking it to. Here is the basics of the program: body = "" File.open(input, 'r') do |file| body = file.read end 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) File.open(input,'w') do |file| file.write new_body end end If the original_section contains "\\" then this gets replaced by "\", can I stop this happening? Jeremy