From: "Mark J. Reed" Date: 2004-01-31T14:29:51+09:00 Subject: Re: regex bug? On Sat, Jan 31, 2004 at 01:07:42PM +0900, Zach Dennis wrote: > key = "file" > attrib = "\\Applications\\4Dapp\\Chess\\" > command = "xcopy [file] /y /s /e i:\\source\\" > command.gsub!( /\[#{key}\]/ , "#{attrib}" ) > puts command > => "xcopy \\ApplicationsDapp\\Chess\\ /y /s /e i:\\source\\" As others have said, '\4' in a gsub string is special. To get around this you need yet another backslash in front of it, which of course means two more backslashes between the double quotes: attrib = "\\Applications\\\\4Dapp\\Chess\\" You can safely double all backslashes in gsub strings, so you might just want to make it special-processing-proof automatically with some preparatory munging of your own: attrib = "\\Applications\\4Dapp\\Chess\\".gsub(/\\/, '\\\\\\') Just as a side note, if you're going to be making literal strings with backslashes, single quotes cut down on the number of doublings required: attrib = '\Applications\4Dapp\Chess\\'.gsub(/\\/, '\\\\\\') -Mark