TalkPHP

TalkPHP (http://www.talkphp.com/forums.php)
-   Tips & Tricks (http://www.talkphp.com/tips-tricks/)
-   -   PHP Script to Extract Email Address from any text (http://www.talkphp.com/tips-tricks/4442-php-script-extract-email-address-any-text.html)

sunilbhatia79 05-27-2009 10:09 AM

PHP Script to Extract Email Address from any text
 
Dear All,

This is the script that allows anyone to extract email addresses from any text.

http://www.sunilb.com/php/php-script...-from-any-text

Give it a run and let me know your comments.

Regards,
Suniil

dschreck 06-11-2009 09:17 AM

i dont really appreciate continuously running into your posts that state nothing more than a link to your own blog...

sunilbhatia79 06-11-2009 09:25 AM

@dschreck I assure you that in future you wont get a chance to complain.

Sakakuchi 06-11-2009 10:19 AM

dscreck is right - it's quite annoying.

Still you could shorten the whole function somehow like that:

PHP Code:

function extractEmail($string)
{
$regEx "/([\s]*)[\._a-zA-Z0-9-]+@[\._a-zA-Z0-9-]+/i";
preg_match_all($regEx$string$emails);

return 
$emails;


(There might be some errors still - since it's not tested)

Salathe 06-11-2009 11:09 AM

It is a shame to see a long, overly complicated function like that which does not match my email address: salathe+spam@talkphp.com since it returns spam@talkphp.com which is not my email address.

(Sorry Sakakuchi, yours wont match my address either)

Sakakuchi 06-11-2009 02:06 PM

jeah, - just wanted to point out that it's possible to solve it with one line of code - when the RegEx is right (well mine is not :-P )


All times are GMT. The time now is 07:19 AM.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0