Note: Content might be outdated!
#TIL about negative lookbehind in Regular Expressions. 🤯
✅ Must match: /something/
✅ Must match: /something/?utm_wtf=yo
❌ Must not match: /another/something/
👉 Does the trick: \/(?<!\w\/)something\/?([\?+].*)?
(Ok, and I also learned it’s bad performance, so don’t use it unless absolutely necessary.)
Not sure the context, but 3v4l.org/r2GDn does the trick as well
Very peculiar context in this case, so yes, a whole lot of better approaches in more regular scenarios.