PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
$s = 'theisml35@berkleyintl.com Mon Apr 27 12';
$s = preg_replace('/ .*$/','',$s);
// $s is now 'theisml35@berkleyintl.com'
Yeah I would go with Apollo's if you can guarantee the format of each line, ie there's no chance of any whitespace creeping in before the email address and so on.
It would indeed, I was thinking also of the data being shuffled into different orders or even being XML-ised (is that a real term?!) or whatever, and simply extracting the email address:
There is an obscure part of RFC 2822 "Internet Message Format" that allows spaces in email addresses. See Appendix A.5. Not that anyone takes advantage of it...
Edit: This post was recovered from search engine cache.
Last edited by McInfo on Tue Jun 15, 2010 3:13 pm, edited 1 time in total.
True enough, but then if we want to validate properly it's going to be a very long regex indeed!
As one article I read highlighted, an email address such as pied-piper@hamlin.doggy is perfectly valid under RFCs 822, 2822 and 3696, however we know that there is no such TLD as .doggy, so full-on validation isn't always the bee's knees.