On Wed, 12 Nov 2003 07:21:51 +0900 "Ron Coutts" <rcoutts / envistatech.com> wrote: > 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. In any ruby string literal, backslash escapes the next character. This is so you can write: puts "\"hello world\"" # => "hello world" It escapes itself, too, so you have a way of printing backslashes: puts "\\" # => \ It works inside single quotes, so you can escape single quotes: puts '\'' # => ' That means it needs to escape itself as well, otherwise you couldn't print a backslash: puts '\\' # => \ This also works inside docstrings. hth, -- Ryan Pavlik <rpav / mephle.com> "*More* hapless visitors? Tsk, and I'm all out of doom quests." - 8BT