title: How to check if the input string is a valid Regular expression?
body: <p>How do you check, in JavaScript, if a string is a proper regular expression that will compile? </p>
  
  <p>For example, when you execute the following javascript, it produces an error.</p>
  
  <pre><code>var regex = new RegExp('abc ([a-z]+) ([a-z]+))');
  // produces:
  // Uncaught SyntaxError: Invalid regular expression: /abc ([a-z]+) ([a-z]+))/: Unmatched ')'
  </code></pre>
  
  <p>How does one determine if a string will be a valid regex or not?</p>