Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

help with preg_match

Status
Not open for further replies.

farley99

MIS
Joined
Feb 12, 2003
Messages
413
Location
US
Hi,

How do i match and email, but not my own email?
change
preg_match('/\b[a-zA-Z0-9\.\_]+@[a-zA-Z0-9\.\-]+\.[a-zA-Z\.\-]+\b/',$customers,$email);
to
preg_match('/\b[a-zA-Z0-9\.\_]+@[a-zA-Z0-9\.\-]+\.[a-zA-Z\.\-]+\b[&not farley99@hotmail.com]/',$customers,$email);

what is the correct syntax for the above?
 
I also don't understand exactly what you want... but I think you might want to ask why you're doing it in one regular expression when your email address isn't really best described by a regular expression at all.

Perhaps, seeing if it's your email address, then if not, see if it's a well formed email address would be a simpler approach?

-Rob
 
I would first check that it is exactly your email address. If that check failed, I would then check to see whether the string contained any well-formed email address. In short, don't try to do it all in one go -- you'll just make yourself crazy.

I've also found it easier to use a "divide and conquer" approach to checking SMTP email addresses for well-formedness. I have a function in faq434-2408 which uses this methodology. The function I provide there can, if you wish, also check to see whether the email address appears in a valid top-level domain.


Want the best answers? Ask the best questions: TANSTAAFL!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top