From: Greg Hacke Date: 2011-05-11T06:16:22+09:00 Subject: gsub and multiple-replacement So I have a file that I am replicating per user. I'm copying the file, Profile_path='/path/to/file/' Profile_file='myfile.txt' copy(Profile_path + Profile_file, Profile_path + username + '.txt') This obviously goes off without a hitch. Now, I need to find and replace three specific values within the file itself. So within the file we have: Record for {username} with {email} from {country} I've read through a ton of material and am looking for the best method. Here are a few caveats: I don't need a temp file. I am unconcerned with overwriting the username.txt file with itself. I have to replace three values within the file. Basically, I want to do something like: text = File.read(Profile_path+username+'.txt') File.open(Profile_path+username+'.txt','w+){|f| f << text.gsub(regex_to_find, text_to_put_in_place)} But what is the best way to do this for three variables? -- Posted via http://www.ruby-forum.com/.