2
Answers

Email-Regular Expression

Resmi Satish

Resmi Satish

10y
819
1
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)