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 test@yahoo.com and it also does what I want: *@somedomain.com, but this doesn't allow test@yahoo.co.uk.

How I should fix it?

Thanks in advance

4

1 回答 1

2

匹配+后添加:(\.\w{2,4})

/^[\w-\.\d*]+@[\w\d]+(\.\w{2,4})+$/
于 2013-02-26T12:30:01.970 回答