Escaping Characters in Ruby Strings and Regular Expressions
In Ruby, a backslash escapes the character after it. In a double-quoted string, \" inserts a quote, \\ a backslash, \n a newline, and \#{} blocks interpolation. A single-quoted string recognizes only \' and \\; every other backslash stays literal. When escaping gets noisy, switch to %q()/%Q() literals or a heredoc.