Reputation: 17873
I want a regex to match these:
/web/search/abc
/web/search/employee/999999999
/web/search/employee/78524152
But not this:
/web/search/employee/123456789
I wrote the following regex for Java, but it does not seem to be working.
/web/search/(?!/(employee/123456789)).*
Can someone tell me the correct regex to do this?
Upvotes: 0
Views: 105
Reputation: 2128
Try the following:
/web/search/(?!(employee/123456789$)).*
The slash was doubled in the negating look-ahead group.
Upvotes: 2
Reputation: 6527
What you tried is : /web/search/(?!/(employee/123456789))
can be represented as
You need to change it as /web/search/(?!employee/123456789)
can be represented as
Upvotes: 3
Reputation: 11132
I would say
str.contains("^/web/search/(?!employee/123456789)")
satisfies your requirements.
Online demonstration here: http://regex101.com/r/dF1eU9
Upvotes: 2
Reputation: 121710
This is because you double the /
in the lookahead. Try with:
/web/search/(?!employee/123456789$).*
Upvotes: 3