title: Using gsub to replace double slashes in Ruby
body: <p>I am having some issues using gsub to replace double slashes. The problem is this:</p>
  
  <p>I built a small script to parse YAML files for a directory location, and then to use that to glob the files in that directory. Say this is the directory it finds:</p>
  
  <pre><code>C:\Program Files\Adobe\Adobe Flash CS3\en\Configuration\ActionScript 3.0\Classes
  </code></pre>
  
  <p>This is a Windows directory, and the backslashes are escaped by YAML parser, so this really gets loaded from parser as:</p>
  
  <pre><code>C:\\Program Files\\Adobe\\Adobe Flash CS3\\en\\Configuration\\ActionScript 3.0\\Classes
  </code></pre>
  
  <p>To use this directory, I wanted to gsub away these double slashes:</p>
  
  <pre><code>path.gsub('\\','/')
  </code></pre>
  
  <p>This call replaced most of the double backslashes in the path, though the script still did not work. When I looked at what the path had become, I found that there was still one backslash that had not been replaced by gsub: </p>
  
  <pre><code>\en
  </code></pre>
  
  <p>What explains this strange behavior?</p>