Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Checking for an email address
Old 04-15-2005, 03:03 PM Checking for an email address
fambi's Avatar
Ultra Talker

Posts: 339
Trades: 0
Hi everyone, any help would be appreciated:

$message = "This is a message and you can reply via myname@email.com";

Does anyone know how i can

a) Check to see if there is an email in this message.
b) Extract the email address from this message.

Thanks in advance and any explanations of the code would be greatly appreciated.
__________________

Please login or register to view this content. Registration is FREE
from a
Please login or register to view this content. Registration is FREE
is easy!
Read this
Please login or register to view this content. Registration is FREE
that uses our
Please login or register to view this content. Registration is FREE
.
fambi is offline
Reply With Quote
View Public Profile Visit fambi's homepage!
 
 
Register now for full access!
Old 04-16-2005, 07:18 AM
leavethisplace's Avatar
Ultra Talker

Posts: 297
Trades: 0
I always use this to verify an email address is properly formatted

PHP Code:
preg_match("/^( [a-zA-Z0-9] )+( [a-zA-Z0-9\._-] )*@( [a-zA-Z0-9_-] )+( [a-zA-Z0-9\._-] +)+$/" $email
With $email being the address to be verified.

I think it will work in what you're looking for, it'll find it anyway, but you need to also extract it, so i suggest using:

PHP Code:
preg_match("/^( [a-zA-Z0-9] )+( [a-zA-Z0-9\._-] )*@( [a-zA-Z0-9_-] )+( [a-zA-Z0-9\._-] +)+$/" $email$matches
Where $matches is a variable, so you would want $matches[0] I THINK! i'm not totally sure as i've never needed to extract an address, check out the PHP manual about the preg_match() function
__________________
A lie gets halfway around the world before the truth has a chance to get its pants on. - Sir Winston Churchill

Please visit my sites:
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
leavethisplace is offline
Reply With Quote
View Public Profile
 
Old 04-16-2005, 07:33 AM
fambi's Avatar
Ultra Talker

Posts: 339
Trades: 0
Thanks.

I haven't tried it yet, but if anyone regexperts would like to comment, that would be appreciated.
__________________

Please login or register to view this content. Registration is FREE
from a
Please login or register to view this content. Registration is FREE
is easy!
Read this
Please login or register to view this content. Registration is FREE
that uses our
Please login or register to view this content. Registration is FREE
.
fambi is offline
Reply With Quote
View Public Profile Visit fambi's homepage!
 
Reply     « Reply to Checking for an email address
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

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





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.19369 seconds with 12 queries