title: Convert a string to regular expression ruby
body: <p>I need to convert string like "/[\w\s]+/" to regular expression.</p>
  
  <pre><code>"/[\w\s]+/" =&gt; /[\w\s]+/
  </code></pre>
  
  <p>I tried using different <code>Regexp</code> methods like:</p>
  
  <p><code>Regexp.new("/[\w\s]+/") =&gt; /\/[w ]+\//</code>, similarly <code>Regexp.compile</code> and <code>Regexp.escape</code>. But none of them returns as I expected.</p>
  
  <p>Further more I tried removing backslashes:</p>
  
  <p><code>Regexp.new("[\w\s]+") =&gt; /[w ]+/</code> But not have a luck.</p>
  
  <p>Then I tried to do it simple:</p>
  
  <pre><code>str = "[\w\s]+"
  =&gt; "[w ]+"
  </code></pre>
  
  <p>It escapes. Now how could string remains as it is and convert to a regexp object?</p>