Solved

regex exclusion

Posted on 2008-10-22
4
567 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
hibernate example issues from command prompt 10 66
ejb example issues 3 55
JAVA API design with micro service cloud in mind 1 82
SequenceInputStream example 3 22
I have been reconstructing a PHP-based application that has grown into a full blown interface system over the last ten years by a developer that has now gone into business for himself building websites. I am not incredibly fond of writing PHP code o…
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:

730 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