I have the following regex to remove last slash from a URL:
(.*)\/
i.e.: http://www.domain.com/clients/
If applied the regex to the example, it does the work fine, but the problem is when the URL does not have the last slash (it occur from time to time). It removes /clients.
How can I avoid this situation?
Regex to remove only last slash in the URL
\/$
explanation:
\/ matches the character / literally
$ assert position at end of a line
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