Solved

regex exclusion

Posted on 2008-10-22
4
568 Views
Last Modified: 2008-10-22
Hi,

I using RegexBuddy to test a java regex expression that will match any string except one with "abc" anywhere in the string.

I.e. Match any strings except the ones with "abc"

1) www.test.com/ad/click-imp/ref?=center=701&pf_rd_i=2&p
2) www.test.com/abc/click-imp/ref=center=701&pf_rd_i=2&p
3) www.test.com/inventory_rep2_mn=70/abc/ws_gh790?%5Fencoding=UTF8
4) www.test.com/promotion/h/ref=xg_2_center/gh_321?%5Fencoding=UTF8

So I want to match string 1 and 4 but not 2 and 3. I tried a bunch of expression but so far the closest I've come is www.test.com/([^abc]++).*

Can an expert help me out?

0
Comment
Question by:acclimate
[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
  • 3
4 Comments
 
LVL 27

Expert Comment

by:ddrudik
ID: 22781760
 Pattern re = Pattern.compile("^(?:(?!abc).)*$",Pattern.DOTALL);
0
 

Author Comment

by:acclimate
ID: 22781833
Hi ddrudik,

I read a bunch of your other posts yesterday :)

I can't do the java commands because the application I'm using will only input regex. DOTALL and Pattern are taken literally.


0
 
LVL 27

Accepted Solution

by:
ddrudik earned 500 total points
ID: 22782239
(?s)^(?:(?!abc).)*$

or:

^(?:(?!abc)(?:.|\n))*$

or:

^((?!abc)(.|\n))*$
0
 
LVL 27

Expert Comment

by:ddrudik
ID: 22782934
Thanks for the question and the points.
0

Featured Post

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

695 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