I'm looking for strings that end with / but not when the string is equal to /[a-z]{2}/ (with the 2 slashes in the pattern)
To exclude the unwanted string I would use :
(?!/[a-z]{2}/)
For strings ending in a slash I'd use :
.*/$
However, my limited knowledge with regular expression doesn't allow me to combine the two patterns. How would I do this ?
This would match :
/en/contact/
This wouldn't :
/en/
The regex should work for you:
^(?!\/[a-z]{2}\/).*\/$
You could check it here.
Update for your added requirement:
^(?!^\/[a-z]{2}\/$).*\/$
The demo.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With