I have a set of urls :
/products
/categories
/customers
Now say a customers is named john, and I want to help john to reac
What you need here is a negative lookahead assertion. What you want to say is "I want to match any string of characters, except for these particular strings." An assertion in a regex can match against a string, but it doesn't consume any characters, allowing those character to be matched by the rest of your regex. You can specify a negative assertion by wrapping a pattern in (?!
and )
.
'/^\/(?!products|categories|admin)(.+)$/'
Note that you might want the following instead, if you don't allow customers names to include slashes:
'/^\/(?!products|categories|admin)([^/]+)$/'