Resmi Satish

Resmi Satish

  • NA
  • 110
  • 75k

Email-Regular Expression

Feb 14 2014 5:23 AM
Hi
I have to allow user to enter only 3 special characters in the email address and restrict them from entering any other special characters.

Below are the special characters

- hyphen

_ underscore

' apostrophe

The regular expression I am using is "\w+[-+.'_]*(\w+)*[\w]@\w+([-.]\w+)*\.\w+([-.]\w+)*"

However this is failing when user is entering an email in the format
test-test'[email protected].

I think the combination of - and ' is not being allowed in the above expression.

Please help to resolve the issue.

Thanks.

Answers (2)