Negative lookbehind

|

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.)

3 reactions on “Negative lookbehind

Reactions are closed.