title: How should I escape this JavaScript regex (RFC 2822 email validator)
body: <p>I have this regex:</p>
  
  <pre><code>/[a-z0-9!#$%&amp;'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&amp;'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?/
  </code></pre>
  
  <p>And I'm escaping the slashes like so:</p>
  
  <pre><code>/[a-z0-9!#$%&amp;'*+\/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&amp;'*+\/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?/
  </code></pre>
  
  <p>This seems to work fine, but I'm concerned that I'm missing an edge case and that the regex is broken by doing this. Is this the proper way to escape slashes?</p>
  
  <p>Or should I instead declare with <code>new</code> like so:</p>
  
  <pre><code>var re = new RegExp(/[a-z0-9!#$%&amp;'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&amp;'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?/);
  </code></pre>
  
  <p>The JavaScript executes correctly without the slashes escaped (in Chrome), but it messes with my editor's (TextMate's) syntax highlighting. On further testing, even <code>new</code> doesn't eliminate the syntax highlighting issue.</p>