title: Convert a regular expression in a string to a regexp object in ruby
body: <p>I take a regular expression as an input from the user and match values against that regex. 
  But, the problem i have is that the input i receive is a string. 
  e.g. <code>"/abc|def/i"</code>
  And i am not able to convert it to a regex object.
  If it try <code>Regexp.new(string)</code>
  it escapes all the characters so i get something like <code>/\/abc|def\/i/</code></p>
  
  <p>I was able to capture the part between the forward slashes using another regex and build a regexp object using it. For the above example, i capture <code>"abc|def"</code> and when i do <code>Regexp.new("abc|def")</code> i get <code>/abc|def/</code> which is what i wanted but i need a way to also add the regexp options(e.g. 'i' in the above example) in the string to the ruby regexp object.</p>
  
  <p>How can i achieve this ???</p>
  
  <p>Also, there must be a easier way to achieve all of this. 
  Any help would be greatly appreciated. </p>