pee2pee
pee2pee

Reputation: 3792

Regex - how to match everything apart from a specific string?

I have this following regex ^(.*)/news which works for the following

However I don't want it to match

Any idea? I've tried ^(?!category)(.*)/news but no luck.

Upvotes: 1

Views: 144

Answers (1)

Robert McKee
Robert McKee

Reputation: 21487

While this (^(.*)(?<!category)/news) might work, I would just do the following on the rule in question instead:

<conditions>
  <add input="{R:1}" pattern="category" negate="true" />
</conditions>

Upvotes: 2

Related Questions