0

I'm trying to validate the local name portion of an email address. The domain name gets pre-populate so I don't have to worry about that part. Is there a regex expression that I can use to do this?

davidst95
  • 29
  • 6
  • You need to validate everything before the `@`? What should be valid/invalid? Emailaddress syntactically correct? Or maybe containing more than x characters? Or having `imaguy` in the pre-`@`part? – Highmastdon Feb 02 '15 at 15:54
  • 1
    What do you mean by `validate the local name`? – Toto Feb 02 '15 at 15:55
  • Hi, by local name I mean validate everything before the @ sign. – davidst95 Feb 02 '15 at 19:45

1 Answers1

0

There are so many answers about this regex. Anyways the following regex might help you

1) Validates whole email id (Ex : firstname.12@gmail.com)

/^[a-z.]+[a-z0-9._%+-]*@[a-z]+[a-z0-9.-]*\.[a-z]{2,4}$/

2) Validates everything except email domain (Ex: firstname.12@)

/^[a-z.]+[a-z0-9._%+-]*@$/

3) Validates everything except '@< domain name >' (Ex: firstname.12)

/^[a-z.]+[a-z0-9._%+-]*$/

Check out the plunker for few other regular expressions also.

http://plnkr.co/edit/00ZdEru4PHQms2fIiUYh?p=preview

Rajeshwar
  • 2,290
  • 4
  • 31
  • 41