1) what is the best scenario to use Regexp.escape?

2) I modify my codes and I get the expected results. But the odd is that 
I have to use 3 backslashes before the 2nd 2. How to explain this.

Thanks,

Li


DATA.each_line do |line|

          if line=~/1\.000000\\\$P1G\\1\.000000/
               line.gsub!(/1\.000000\\\$P1G\\1\.000000/, 
'2.000000\\\$P1G\\\2.000000')
               puts line
          end
  end

###same DATA as the first post##

####screen output####

ruby FC500_3.rb
xxx\2.000000\$P1G\2.000000\xxx
yyyy\2.000000\$P1G\2.000000\xxx
xxx\2.000000\$P1G\2.000000\xxx
yyyy\2.000000\$P1G\2.000000\xxx
xxx\2.000000\$P1G\2.000000\xxx
yyyy\2.000000\$P1G\2.000000\xxx




-- 
Posted via http://www.ruby-forum.com/.