Why does String#gsub double content?
问题 s = \"#main= \'quotes\' s.gsub \"\'\", \"\\\\\'\" # => \"#main= quotes\'quotes\" This seems to be wrong, I expect to get \"#main= \\\\\'quotes\\\\\'\" when I don\'t use escape char, then it works as expected. s.gsub \"\'\", \"*\" # => \"#main= *quotes*\" So there must be something to do with escaping. Using ruby 1.9.2p290 I need to replace single quotes with back-slash and a quote. Even more inconsistencies: \"\\\\\'\".length # => 2 \"\\\\*\".length # => 2 # As expected \"\'\".gsub(\"\'\", \"