Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

RegExp - "NOT Email"

Posted on 2004-08-27
7
Medium Priority
?
422 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

Looking for a new Web Host?

Lunarpages' assortment of hosting products and solutions ensure a perfect fit for anyone looking to get their vision or products to market. Our award winning customer support and 30-day money back guarantee show the pride we take in being the industry's premier MSP.

Question has a verified solution.

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

FAQ pages provide a simple way for you to supply and for customers to find answers to the most common questions about your company. Here are six reasons why your company website should have a FAQ page
When crafting your “Why Us” page, there are a plethora of pitfalls to avoid. Follow these five tips, and you’ll be well on your way to creating an effective page.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Suggested Courses

618 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