2

I came across a reg ex for email validation:

^[^@]+([@]{1})[0-9a-zA-Z\\._-]+([\\.]{1})[a-zA-Z0-9\\._-]+$

This is a pattern which i found in a standard Adobe Day CQ email validation code. I have a problem with the last matching group [a-zA-Z0-9\\._-]+ where it allows multiple occurrences of digits as well which allows me to enter as a valid input someone@else.9. Can somebody please help me understand why do we need a digit value in the last matching group.

Any help is appreciated. Please guide me what else regex can be used to validate a standard day to day email input.

brandonscript
  • 68,675
  • 32
  • 163
  • 220
TechNiks
  • 110
  • 9
  • 1
    Already answered this question once today: http://stackoverflow.com/questions/21171549/how-do-i-run-this-regex-in-php-that-parse-full-email-address-with-name/21171732#21171732 Same answer stands. Check for spaces, then just send it. – brandonscript Jan 17 '14 at 07:09
  • 1
    The regex is horribly broken, as it will allow stuff like `me@...`. Also the `{1}` is a typical newbie mistake - it's harmless but also completely useless. Anyway, don't use regex for email validation. – tripleee Jan 17 '14 at 07:10
  • Check remus' answer above, it is excellent. – e h Jan 17 '14 at 11:11

0 Answers0