?
Solved

RegExp - "NOT Email"

Posted on 2004-08-27
7
Medium Priority
?
418 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
7 Comments
 
LVL 16

Accepted Solution

by:
Walter Ritzel earned 672 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 664 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 664 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Color can increase conversions, create feelings of warmth or even incite people to get behind a cause. If you want your website to really impact site visitors, then it is vital to consider the impact color has on them.
Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
The viewer will learn how to count occurrences of each item in an array.
The is a quite short video tutorial. In this video, I'm going to show you how to create self-host WordPress blog with free hosting service.
Suggested Courses
Course of the Month8 days, 10 hours left to enroll

764 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