Hello,
I'm hoping for some help with a regex that has me stumped. My skill with regex is rather rudimentary.
To start, here are a couple of example URLs, and whether I want to match them or not:
collection/col1 // MATCH
collection/col2 // FAIL
collection/col1/products/pro1 // FAIL
My criteria:
- One single regex (cannot be multiple expressions)
- I have a list of "col"s to fail on. For example, I do not want to match if specifically "col2" or "col3" are in the URL
- Aside from col2 or col3, i can have any col[#] in the URL
- Even if a valid col# is in the URL, the expression MUST fail if
/products/
appears anywhere. The URL structure is such that if/products/
appears anywhere, it will always be after/collections/col#
Here are expressions I've come up with, but I'm missing how to make the expression definitely fail if /products/
is anywhere in it. Is this possible?
collections\/(?!col2|col3)(?!\/products\/)
collections\/{?!col2|col3)[0-9a-zA-Z-_]+(?!\/products\/)
// And like 200 other things I tried that I didn't record
Thank you for any assistance.