Reputation: 15299
I am doing a email validation. I would like to test the email
- the user entered properly end with some domain. usually the domain contains min 2 letters to max 3 letters. and it should prepended with .
notation.
I tried like this, but not working properly
\.+{2}|{3}$
what is the correct approach to find this?
Upvotes: 0
Views: 59
Reputation: 174776
The pattern would be,
\..{2,3}$
Explanation:
\.
Literal dot symbol..{2,3}$
Allows two or three characters after the dot followed by the end of the string.Upvotes: 0
Reputation: 388406
I think it should be
/.+\..{2,3}$/
where
.+
says it should have 1 or more characters\.
says there should be a .
.{2,3}
says there should be 2-3 chars(you can say something like [a-z]{2,3}
to allow only alphabets)Upvotes: 2