TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 05-27-2009, 10:09 AM   #1 (permalink)
The Wanderer
 
Join Date: Nov 2007
Location: Mumbai, India
Posts: 24
Thanks: 0
sunilbhatia79 is on a distinguished road
Default 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
__________________
Sunil Bhatia www.twitter.com/sunilbhatia79 - Follow me on Twitter
PHP5 Tutorials
Career Articles
sunilbhatia79 is offline  
Reply With Quote
Old 06-11-2009, 09:17 AM   #2 (permalink)
The Contributor
 
dschreck's Avatar
 
Join Date: Nov 2007
Location: California
Posts: 82
Thanks: 0
dschreck is on a distinguished road
Default

i dont really appreciate continuously running into your posts that state nothing more than a link to your own blog...
__________________
Where I Ramble: http://www.iwilldomybest.com/
What I do: Zynga Game Network
Senior Software Engineer at CityVille
dschreck is offline  
Reply With Quote
Old 06-11-2009, 09:25 AM   #3 (permalink)
The Wanderer
 
Join Date: Nov 2007
Location: Mumbai, India
Posts: 24
Thanks: 0
sunilbhatia79 is on a distinguished road
Default

@dschreck I assure you that in future you wont get a chance to complain.
__________________
Sunil Bhatia www.twitter.com/sunilbhatia79 - Follow me on Twitter
PHP5 Tutorials
Career Articles
sunilbhatia79 is offline  
Reply With Quote
Old 06-11-2009, 10:19 AM   #4 (permalink)
The Contributor
 
Sakakuchi's Avatar
 
Join Date: Feb 2009
Posts: 64
Thanks: 1
Sakakuchi is on a distinguished road
Default

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)
Sakakuchi is offline  
Reply With Quote
Old 06-11-2009, 11:09 AM   #5 (permalink)
Moderateur
RegEx Guru PHP Guru Top Contributor Advanced Programmer 
 
Salathe's Avatar
 
Join Date: Apr 2007
Posts: 1,393
Thanks: 5
Salathe is on a distinguished road
Default

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)
Salathe is offline  
Reply With Quote
Old 06-11-2009, 02:06 PM   #6 (permalink)
The Contributor
 
Sakakuchi's Avatar
 
Join Date: Feb 2009
Posts: 64
Thanks: 1
Sakakuchi is on a distinguished road
Default

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 )
Sakakuchi is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Nginx Rewrite Causing Wrong Path for PHP Script stewart General 0 11-09-2008 12:32 AM
email fill in form help? PHP sacred_tinker Absolute Beginners 19 05-28-2008 05:58 AM
Activation Keys vujsa Advanced PHP Programming 2 12-11-2007 07:43 PM
PHP Script to Extract Email Address from any text sunilbhatia79 Show Off 5 11-15-2007 01:53 PM
Creating a PHP ACL and even Rat out Users using Proxies! Wildhoney General 0 09-22-2007 10:48 AM


All times are GMT. The time now is 09:25 PM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design