0

I have this regular expression for email validation:

/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/

But this is not working for emails like:

test+1@gmail.com

How do I change the above regular expression for this requirement?

pranami
  • 1,381
  • 5
  • 22
  • 43
  • 2
    Does this answer your question? [How to validate an email address in JavaScript](https://stackoverflow.com/questions/46155/how-to-validate-an-email-address-in-javascript) – Kinglish Jul 08 '21 at 04:02
  • surely there must be many examples of email validation regex all over S.O. – Kinglish Jul 08 '21 at 04:14
  • Does this answer your question? [How to validate an email address using a regular expression?](https://stackoverflow.com/questions/201323/how-to-validate-an-email-address-using-a-regular-expression) – Rahul Kumar Jul 08 '21 at 04:35

2 Answers2

1

You forgot to add RegEx for the '+' symbol

^\w+([\.+-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$
Daksharaj kamal
  • 526
  • 1
  • 4
  • 11
0

+ was not icluded in your regex pattern. I have added that. Hope this works.

^\w+([\.\-\+]?\w*)*@\w+([\.-]?\w+)*(\.\w{2,3})+$

Nitheesh
  • 19,238
  • 3
  • 22
  • 49