S
Sriram Varahan
Hello,
I have a string as a = "&0&1"
I need to pass this value with the ampersand escaped to another command
in my program.
So I tried something like this:
irb(main):038:0> a.gsub(/&/,"\\&")
=> "&0&1"
But if I replace the & with some other variable I get it properly
working:
irb(main):049:0> a.gsub(/&/,"\\g")
=> "\\g0\\g1"
Any explanation on why this is happening and how to go about escaping
the &.
Thanks.
Sriram Varahan.
I have a string as a = "&0&1"
I need to pass this value with the ampersand escaped to another command
in my program.
So I tried something like this:
irb(main):038:0> a.gsub(/&/,"\\&")
=> "&0&1"
But if I replace the & with some other variable I get it properly
working:
irb(main):049:0> a.gsub(/&/,"\\g")
=> "\\g0\\g1"
Any explanation on why this is happening and how to go about escaping
the &.
Thanks.
Sriram Varahan.