- For individual users
- Instant access to solutions
- Ask your tech questions
- Start your 30-day Free Trial
Main Topics
Browse All TopicsShort description:
I need a regex that finds all strings that look like
"..." <clark.kent@mycompany.com>
, and where ... does not include any of the words "clark", "kent" or "superman" (case-insensitive).
Because of the way the expression will be implemented into another application, I need ONE regex (not a combination), and I need a POSITIVE match (=~, not !~), and I also can't use functions via the /e switch.
Anybody an idea?
---
Background Info:
Suppose, you receive e-mails on your email-address, clark.kent@mycompany.com. Usually you receive them with SMTP addresses like "Clark Kent" <clark.kent@mycompany.com>
Among these mails you receive a lot of spam that is usually sent to addresses like "Members" <clark.kent@mycompany.com>
To do some pre-filtering of potential spam, you want to find all those mails that are sent to "some_string" <clark.kent@mycompany.com>
So you try to write a regex that matches exactly the above mentioned string, and this my problem. I can easily write a regex that finds all "some_string" mail addresses that _do_ have "Clark" or "Kent" in them (i.e. that _does_ contain one of a set of substrings):
if ($sendto =~ m/\".*?(clark|kent).*?\" <clark\.kent@mycompany\.co
But I utterly fail to simply do a negation on the (clark|kent) part. I've tried fiddling around with the negative lookup (?!) and some other things, but those did not work.
Any solution appreciated.
This question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Business Accounts
Answer for Membership