News for hackers. Stuff that matters.
Re:Email Regex that works 99.99% by falcolas on Sunday February 22, 2015 @08:44AM (#9089370)
After extensive research, I have finally come up with a way to improve upon 99.99%. I have come up with a regex which will work for 100% of email addresses, and a significant number of regex engines, as an added bonus! Behold:

    .*@.*
/s
Re:Email Regex that works 99.99% by moe on Sunday February 22, 2015 @09:20AM (#9089497)

  $ nc localhost 25
  220 uhura.z ESMTP
  MAIL FROM:me
  250 2.1.0 Ok
  RCPT TO:root
  250 2.1.5 Ok
  DATA
  354 End data with <CR><LF>.<CR><LF>
  Look ma, no @!
  .
  250 2.0.0 Ok: queued as 8DB653E0065
  quit
  221 2.0.0 Bye
Re:Email Regex that works 99.99% by falcolas on Sunday February 22, 2015 @09:32AM (#9089528)
/bow

.* it is!

Re:Email Regex that works 99.99% by madaxe_again on Sunday February 22, 2015 @09:01AM (#9089429)
Your verbosity is outlandish.

.*

will match all email addresses, and as an additional feature, all other strings too!

As we all know, more functionality with less code is better, therefore, this is clearly superior to all other regexes.

Re:Email Regex that works 99.99% by fphilipe on Sunday February 22, 2015 @08:49AM (#9089386)

    .+@.+
Should do the trick
Re:Email Regex that works 99.99% by falcolas on Sunday February 22, 2015 @08:55AM (#9089404)
I considered that one, but I'm sure there's some system out there which doesn't require an account name ahead of the "@" symbol. We're shooting for 100% accuracy, after all. ;)
Re:Email Regex that works 99.99% by sirn on Sunday February 22, 2015 @08:59AM (#9089420)
In that case, let me improve it further :-)

    /@./
Though I'm not really sure there could be an email without username part.
Re:Email Regex that works 99.99% by arthurfm on Sunday February 22, 2015 @09:24AM (#9089512)
What regex would you suggest to match all e-mail addresses contained within an arbitrary body of text (as opposed to a single text field where you don't have worry about other text strings)?
Re:Email Regex that works 99.99% by falcolas on Sunday February 22, 2015 @09:36AM (#9089535)
The same one. If it has an '@' symbol embedded in it, it might be an email address. The only way to know for certain is to query the server its attached to.

Of course, if you're really trying to scrape email addresses reliably, looking for the '@' won't work reliably, since people are used to obfuscating their email with [at] or (at) to protect against spam (well, more spam). You will probably need to dive into AI theory to more reliably get email addresses.