Many times before when I was supposed to collect emails from users I was googling to find some regexp to verify email syntax. At least I was aware that regexp challenging email address syntax is a bullshit ;) I was working few years as Unix sysadmin mostly on mail servers, so I had some idea how RFCs related to email are bloated ;) and contain so many exceptions ;)
From some time I do use following regexp to verify email address:
This should check if:
- there is @ sign somewhere inside
- at least one character is before @ sign
- at least 3 chars (with one dot) are after @ sign
Why such simple rules? I have found comment on StackOverflow, that man should step back and think why is checking email address?
I want just to help users and stop them making simple mistakes in theirs emails. Like not providing @ at all. Or eating .com in gmail.com address. And that’s it – email will be probably shortly after that verified with only reliable method via sending email to this address.
And if You insist to verify emails with more strict regular expression, please do remember that plus sign is perfectly valid character before @. Many regexps found via google are forgetting that…
This make sense for me.
Leave a comment