title: Create Regex from String stored in variable with escaped characters (Ruby)
body: <p>I'm trying to build a regex from a string object, which happens to be stored in a variable.</p>
  
  <p>The problem I'm facing is that escaped sequences (in the string) such "\d" doesn't make to the resulting regex.</p>
  
  <pre><code>Regexp.new("\d") =&gt; /d/
  </code></pre>
  
  <p>If I use single quotes, tough, it works flawless.</p>
  
  <pre><code>Regexp.new('\d') =&gt; /\d/
  </code></pre>
  
  <p>But, as my string is stored in a variable, I always get the double-quoted string. </p>
  
  <p>Is there a way to turn a double-quoted string to single-quoted string, so that I could use in the Regexp constructor ?</p>
  
  <p>(I'd like to use the string interpolation feature of the double quotes)</p>
  
  <p>ex.:</p>
  
  <pre><code>email_pattern = "/[a-z]*\.com"
  whole_pattern = "to: #{email_pattern}"
  Regexp.new(whole_pattern)
  </code></pre>
  
  <p>For better readability, I'd like to avoid escaping escape characters.</p>
  
  <pre><code>"\\d"
  </code></pre>