1

I want to validate email addresses, it's easy, there are lots of RegEx while I search Google, but here, I want to also allow *@domain.com, here is what I have right now:

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

This works just fine for regular email addresses like [email protected] and it also does what I want: *@somedomain.com, but this doesn't allow [email protected].

How I should fix it?

Thanks in advance

4
  • «I want to validate email addresses, it's easy» - Yeah, sure xD Commented Feb 26, 2013 at 12:29
  • @ÁlvaroG.Vicario :)) I meant the regular ones not allowing *@etc.vom :-D Commented Feb 26, 2013 at 12:30
  • Please.. don't use some lame regex to validate email addresses. It is extremely annoying if e.g. + is not accepted in the localpart. Commented Feb 26, 2013 at 12:31
  • @ThiefMaster do you have any other suggestions? Commented Feb 26, 2013 at 12:35

1 Answer 1

2

Add + after (\.\w{2,4}) match:

/^[\w-\.\d*]+@[\w\d]+(\.\w{2,4})+$/
Sign up to request clarification or add additional context in comments.

Comments

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.