I tried this :
irb(main):125:0> a = "ab%c"
=> "ab%c"
irb(main):126:0> a.gsub("%", '\\')
=> "ab\\c"
irb(main):127:0>
whereas expected output is:
ab\c
it did not work.
Thanks in advance.
Update: ruby version
ruby -v
ruby 1.8.7 (2011-06-30 patchlevel 352) [x86_64-linux]
in
"ab\\c"
backslash\
is being escaped using character\
. you can verify this withputs