0

I use this regex in Rails to check that an email address contains the basic parts:

/.+@.+\..+/i

I'm trying to translate that to javascript to do the same validation client side. I've tried a method given here on SO:

var translated_regex = /.+@.+\\..+/i

and the gem js_regex:

var translated_regex = /.+@.+\\..+/

But translated_regex.test('[email protected]') don't work in neither of those cases.

What am I doing wrong or miss here?

1
  • No need to double escape the period Commented Jun 25, 2017 at 10:36

1 Answer 1

2

Don't double escape the dot:

var translated_regex = /.+@.+\..+/
console.log(translated_regex.test('[email protected]'))

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks! Too bad the mentioned methods are erroneous.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.