0

I'm trying to lightly validate an email address and I'm almost there but I can't figure out how to force the local part to include a dot.

The general format that should pass the validation is :

firstname.lastname@subdom.domain.com  

where the local part must contain a dot or more than one dot, but not consecutively. The dot cannot start the email. Apostrophes and hyphens are ok but not as beginning characters.

name@subdom.domain.com must fail.

This is what I have, but its still validating name@subdom.domain.com

^(\w+)([\-.'][\w]+)*@(\w[\-\w]*\.){1,3}([A-Za-z]){2,6}
aelor
  • 10,892
  • 3
  • 32
  • 48
TSage
  • 17
  • 3
  • This isn't a duplicate. The suggested duplicate is about an issue with subdomains and dots, subdomains work properly in this regex. This is about the local part. – TSage Jun 10 '14 at 02:55

1 Answers1

0

replace the * with a +

i.e. 0 or more with 1 or more

^(\w+)([\-.'][\w]+)*@(\w[\-\w]*\.){1,3}([A-Za-z]){2,6}
                   |
                  here
aelor
  • 10,892
  • 3
  • 32
  • 48