>>>>> "n" == noreply  <noreply / rubyforge.org> writes:

 not really a bug, it's how ruby interpret \ in #sub

>> puts 'abcde'.sub(/c/, '\&')
n> abcde

 it's the normal \&

>> puts 'abcde'.sub(/c/, '\\&')
n> abcde

 When ruby build the string, it will give the 2 characters '\&' which will
 be interpreted by the regexp engine like in 1)

>> puts 'abcde'.sub(/c/, '\\\&') 
n> ab\&de

 When ruby build the string, it will give \\&  and it will do the same than
 in 4)


>> puts 'abcde'.sub(/c/, '\\\\&') 
n> ab\&de

 This give the string '\\&', i.e. 2 characters '\' and '&'

>> puts 'abcde'.sub(/c/, '\\\\\&')
n> ab\cde

 This give '\\\&' , i.e. '\' with '\&'



Guy Decoux