3gwebtrain
3gwebtrain

Reputation: 15299

Regexp - find my email Id end with valid domain

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

Answers (2)

Avinash Raj
Avinash Raj

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

Arun P Johny
Arun P Johny

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

Related Questions