Reputation: 405
I would like to match all URLs, except some. I have the regex below. This excludes URLs that end with .html
, but I also want to exclude URLs that have (somewhere) 'sub-cat' or 'sub-cat2' in it.
This is however not working currently. What is going wrong? Thanks!
/webshop/category/.*+$(?<!\.html|sub-cat|sub-cat2)
Upvotes: 1
Views: 141
Reputation: 785068
You may use a negative lookahead condition with alternations:
^(?!.*(sub-cat|sub-cat2|\.html$).*/webshop/category/.+$
(?!.*(sub-cat|sub-cat2|\.html$)
will fail your match if URL ends with .html
or if it has sub-cat
or sub-cat2
anywhere.
Upvotes: 1