I want to create a reg-ex which matches URLs that does not end with a particular word(s). Here are some examples:
I want to match:
https://google.com/default-category/all-products.html/22-oz-full-color-stadium-cup-white
https://google.com/catalog/product/view/id/9351/s/plant-award/category/3/
https://google.com/all-products/volleyball/stress-shape
And, I don't want to match:
https://google.com/all-products/timber-bases-other/bases-gloves/tic-tac-1/tic-tac-1/
https://google.com/all-products/timber-bases-other/bases-gloves/tic-tac-1/tic-tac-1/tic-tac-1/tic-tac-1/tic-tac-1/
Here is the regex I am using:
https?:\/\/(www\.)?google\.com\/(default-category\/all-products\.html|catalog\/product\/view\/id|all-products)\/[\w-\/]+(?!tic-tac-1)
The problem is, all the words follow a similar pattern. The wildcard ([\w-]+\/?)+
matches even the word tic-tac-1
.
How do I ensure it does not happen?
Here is the RegExr link where I try it out: https://regexr.com/4chb8