Here\'s a regex for validating emails - \\S+@\\S+\\.\\S+
, I didn\'t write it. I\'m new to Regular Expressions and do not understand them all that well.
What's wrong with the above RegEx?
The RFC822 standard for email addresses is very loose, so it is hard to find a terse regular expression that captures all possible valid emails. The matter is complicated by the fact that not every mail server/client enforces this standard, so the actual data might be
While you can certainly guess, or enforce a particular format, writing an ad-hoc expression is pretty much a guarantee that you will have either lots of junk email addresses or deny valid ones.
What's a good RegEx for validating emails?
This is the reference regex for validating against the RFC, its implemented as a perl module here, but is also the final listing in O'Reillys "Mastering Regular Expressions"
Mail::RFC822::Address