From: Paul Fox Date: 2007-12-04T18:18:01+09:00 Subject: changing a files' content hi all, i have a text file with various lines, and i want to alter some of these using regex and gsub. so i have patterns={/some_pattern/=>"replacement text"} and i'm thinking this: in = File.open(filename) while (line=in.gets) if line.strip =~ pattern line.gsub(pattern,patterns[pattern]) end end but i'm not sure if that's efficient? and of course, i'm struggling on the best way of writing those changes back into the file. any thoughts? thanks, f. -- Posted via http://www.ruby-forum.com/.