Solved

RegExp - "NOT Email"

Posted on 2004-08-27
7
412 Views
Last Modified: 2008-03-06
Hi, experts, and thanks for your attention!

I'm a php developer and i badly need to create RegExp evaluating "NOT E-mail", so when i compare string which is not email preg_match will give me "true".

For some reasons i can't just revert preg_match results, because there is a routine which process many patterns and strings and works as described.

By correct E-mail i mean something like *@*.*

Thanks in advance.
0
Comment
Question by:Zmey2
  • 2
7 Comments
 
LVL 16

Accepted Solution

by:
Walter Ritzel earned 168 total points
ID: 11915736
I dont know this kind of regexp validation, just regexps that validates if a email type is a valid one, like this expression:
^(([A-Za-z0-9]+_+)|([A-Za-z0-9]+\-+)|([A-Za-z0-9]+\.+)|([A-Za-z0-9]+\++))*[A-Za-z0-9]+@((\w+\-+)|(\w+\.))*\w{1,63}\.[a-zA-Z]{2,6}$

And in my code, i test if a email is invalid by false return.

Regards,

Walter.
0
 
LVL 18

Assisted Solution

by:arantius
arantius earned 166 total points
ID: 11918487
(!preg_match("^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$", $variable))
0
 

Assisted Solution

by:algid
algid earned 166 total points
ID: 12111191
pattern:
/^(?!([a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$))/

code snippet:
preg_match('/^(?!([a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$))/', $string)
0
 

Expert Comment

by:algid
ID: 12456254
wpcortes and arantius gives regexp which checks whether given string IS EMAIL and then inverses the result. Asker clearly stated it's not what he needs. He needs regexp NOT E-MAIL. Only my solution is valid in this case.
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Envision that you are chipping away at another e-business site with a team of pundit developers and designers. Everything seems, by all accounts, to be going easily.
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
This tutorial walks through the best practices in adding a local business to Google Maps including how to properly search for duplicates, marker placement, and inputing business details. Login to your Google Account, then search for "Google Mapmaker…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

821 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question