'React Route match only if string does not contain 'abc'
I am matching routes based on Regex in my react app. Currently I match all chars except / to find out any subroute of a parent route app/parent
My regex for routing:
'/app/parent/:myId([^/]+)/:section?/:subsection?
I am creating a new route app/parent/myroute but above regex is matching everything except / and routing me to my old path.
I want to match only those routes that don't contain myroute string. How do I do that in React? All existing routes should work and my new route should too.
I tried to use negative lookahead operator:
^(?:(?!\bmyroute\b).)*$ but it's not working though.
What am I missing here?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
