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 11-14-2007, 02:31 PM   #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

I have developed a function that you can embed in your PHP applications that will help you extract email addresses from a given piece of text.

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

Please leave behind comments for suggestions and questions.

Sunil
__________________
Sunil Bhatia www.twitter.com/sunilbhatia79 - Follow me on Twitter
PHP5 Tutorials
Career Articles
sunilbhatia79 is offline  
Reply With Quote
Old 11-14-2007, 06:06 PM   #2 (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

Can you explain why you chose to tokenise the string over using regular expressions to extract the email addresses? Also, the patterns used to remove "invalid" characters and determine valid addresses are far from ideal. For example, they would allow _@-.zz but disallow me+test@domain.com (the first being an invalid address and the second a valid one).
Salathe is offline  
Reply With Quote
Old 11-14-2007, 06:41 PM   #3 (permalink)
La Vida es Sueño
Advanced Programmer Top Contributor 
 
Wildhoney's Avatar
 
Join Date: Sep 2007
Location: Oldham
Posts: 2,280
Thanks: 90
Wildhoney is on a distinguished road
Default

You know, Salathe, even I forget that the + in an email address is valid from time-to-time. Such as like if my email was adam@example.com, I could specify it as talkphp+adam@example.com, and it'll come right to my inbox at adam@example.com. Many registration forms don't actually check for duplicates based on this either, if they allow the + then often they would class it as a unique email address.
__________________
The man who comes back through the Door in the Wall will never be quite the same as the man who went out.
Send a message via AIM to Wildhoney Send a message via MSN to Wildhoney Send a message via Yahoo to Wildhoney
Wildhoney is offline  
Reply With Quote
Old 11-15-2007, 03:31 AM   #4 (permalink)
The Wanderer
 
Join Date: Nov 2007
Location: Mumbai, India
Posts: 24
Thanks: 0
sunilbhatia79 is on a distinguished road
Default

Thank you guys... I will surely take your feedback and improve the script...

Thanks again
__________________
Sunil Bhatia www.twitter.com/sunilbhatia79 - Follow me on Twitter
PHP5 Tutorials
Career Articles
sunilbhatia79 is offline  
Reply With Quote
Old 11-15-2007, 01:00 PM   #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

Just to clarify, your use of the + sign within an email address is incorrect Wildhoney. Email sent to talkphp+adam@example.com would be routed through to talkphp@example.com. I very often use it to label things that I think will be spammy or to specify 'groups' which my mail software can then filter incoming mail by. Sadly, all too many websites refuse to accept that the + symbol is a valid character when used like this. :(

Thanks for listening Sunil, and good luck with your work on the script.
Salathe is offline  
Reply With Quote
Old 11-15-2007, 01:53 PM   #6 (permalink)
La Vida es Sueño
Advanced Programmer Top Contributor 
 
Wildhoney's Avatar
 
Join Date: Sep 2007
Location: Oldham
Posts: 2,280
Thanks: 90
Wildhoney is on a distinguished road
Default

Oh yes, I remember now. See how easy I forget this technique. I have used it in the past, admittedly, not in a while.
__________________
The man who comes back through the Door in the Wall will never be quite the same as the man who went out.
Send a message via AIM to Wildhoney Send a message via MSN to Wildhoney Send a message via Yahoo to Wildhoney
Wildhoney 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


All times are GMT. The time now is 09:19 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