2levelsabove Posted September 12, 2008 Share Posted September 12, 2008 any feedback is appreciated. function extract_emails_from($string){ preg_match_all("/[\._a-zA-Z0-9-]+@[\._a-zA-Z0-9-]+/i", $string, $matches); return $matches; } Quote Link to comment https://forums.phpfreaks.com/topic/123974-can-this-email-addres-finder-function-be-improved/ Share on other sites More sharing options...
Maq Posted September 12, 2008 Share Posted September 12, 2008 I'm not a regex expert, but try this regular expression: $pattern = "/\b[^@\s]+@\S+?\.[a-z]+\.?[a-z]+\b/i"; It will match emails even if they have () or around them. Quote Link to comment https://forums.phpfreaks.com/topic/123974-can-this-email-addres-finder-function-be-improved/#findComment-639993 Share on other sites More sharing options...
corbin Posted September 12, 2008 Share Posted September 12, 2008 His would still find the email address in () or <>. Quote Link to comment https://forums.phpfreaks.com/topic/123974-can-this-email-addres-finder-function-be-improved/#findComment-640189 Share on other sites More sharing options...
Maq Posted September 13, 2008 Share Posted September 13, 2008 His would still find the email address in () or . Yeah sorry, I was just trying to throw something out there to help him out. Like I said, I'm not a regex expert. Quote Link to comment https://forums.phpfreaks.com/topic/123974-can-this-email-addres-finder-function-be-improved/#findComment-640314 Share on other sites More sharing options...
2levelsabove Posted September 13, 2008 Author Share Posted September 13, 2008 Thanks a lot guys! you guys are awesome! Quote Link to comment https://forums.phpfreaks.com/topic/123974-can-this-email-addres-finder-function-be-improved/#findComment-640688 Share on other sites More sharing options...
effigy Posted September 15, 2008 Share Posted September 15, 2008 It depends on how flexible or strict you want to be. For example, according to the RFC here, you could miss some addresses. Quote Link to comment https://forums.phpfreaks.com/topic/123974-can-this-email-addres-finder-function-be-improved/#findComment-641938 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.