From: Sriram Varahan Date: 2010-01-13T21:49:39+09:00 Subject: Ruby Regex 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. -- Posted via http://www.ruby-forum.com/.