J
Jani Soila
I tried to replace "'" characters with "\'" strings using gsub. What
happened instead was something completely different. Am I missing
something here?
(in irb)
irb(main):001:0> s = "a'b'"
=> "a'b'"
Unexpected result
irb(main):002:0> s.gsub(/'/, "\\'")
=> "ab'b"
Also with this
irb(main):003:0> s.gsub(/'/, '\\\'')
=> "ab'b"
However this works
irb(main):004:0> s.gsub(/'/, "\\x'")
=> "a\\x'b\\x'"
Thank you for your help!
-js
happened instead was something completely different. Am I missing
something here?
(in irb)
irb(main):001:0> s = "a'b'"
=> "a'b'"
Unexpected result
irb(main):002:0> s.gsub(/'/, "\\'")
=> "ab'b"
Also with this
irb(main):003:0> s.gsub(/'/, '\\\'')
=> "ab'b"
However this works
irb(main):004:0> s.gsub(/'/, "\\x'")
=> "a\\x'b\\x'"
Thank you for your help!
-js