Hi,

Why can't I substitute a single backslash in a string?

a = "\\6"
p a     # => "\\6"
puts a  # => \6
p a.sub('\', '')

Expected: "\6"
Got:
j:4: unterminated string meets end of file
j:4: parse error, unexpected $, expecting ')'

If I change the replacement to 'c', I get a new error:

j:4: parse error, unexpected tIDENTIFIER, expecting ')'
puts a.sub('\', 'c')
                  ^
j:4: unterminated string meets end of file

Both substitution work fine when the pattern is a regular character.
The substitution also works if num('\') is a multiple of 2, example:
a = '\\6'
p a     # => "\\6"
puts a  # => \6
p a.sub('\\', '')

Expected: "6"
Got: "6"

Thanks for your time.