From: Ron Coutts Date: 2003-11-12T07:21:51+09:00 Subject: Backslash substitution question I'm having trouble with backslashes and I don't know what is wrong. I can't seem to write and expression that will evaluate to a string containing a single backslash character as in "\". It seems that "\\" in Ruby evaluates to "\\" not to "\" as I would expect. Below are a few things I've tried. If anyone could send back a quick answer it would be much appreciated. res = "c:/foo/bar".gsub(/\//, "\\") # -> c:\\foo\\bar res = "c:/foo/bar".gsub(/\//, '\\') # -> c:\\foo\\bar #res = "c:/foo/bar".gsub(/\//, "\") # -> syntax error - unterminated string meets end of file #res = "c:/foo/bar".gsub(/\//, '\') # -> syntax error - unterminated string meets end of file res = "c:/foo/bar".gsub(/\//) { "\\"} # -> c:\\foo\\bar Ron