I've got such a regex in ruby on rails
/\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\Z/i
I'd like to use same email validation logic in front end.
I've tried to use the .inspect method in the irb console, it doesn't seem to return a js valid regular expression.
As far as I understand \A is a ^, \Z is a $. [-a-z0-9] probably translates to [a-zA-Z0-9]. Not sure about the rest.
I've tried to look for an online converter too, couldn't find one. Answers in other similar topics in SO didn't work.
What's the easiest way to translate such regex from ruby into javascript?
[-a-z0-9]should remain unchanged. It matches any lower-case letter, a digit, or the dash (-). The dash has no special meaning at the start of a character class.