title: Translate Ruby regex into JavaScript
body: <p>I've got such a regex in ruby on rails</p>
  
  <pre><code>/\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\Z/i
  </code></pre>
  
  <p>I'd like to use same email validation logic in front end.</p>
  
  <p>I've tried to use the <code>.inspect</code> method in the <code>irb</code> console, it doesn't seem to return a js valid regular expression.</p>
  
  <p>As far as I understand <code>\A</code> is a <code>^</code>, <code>\Z</code> is a <code>$</code>. <code>[-a-z0-9]</code> probably translates to <code>[a-zA-Z0-9]</code>. Not sure about the rest.</p>
  
  <p>I've tried to look for an online converter too, couldn't find one. Answers in other similar topics in SO didn't work.</p>
  
  <p>What's the easiest way to translate such regex from ruby into javascript?</p>