Forum Discussion
neufpas_66702
May 25, 2011Nimbostratus
strip trailing slashes
Given a string with an arbitrary number of slashes (HTTP::path for example), how do I remove the final slash if it has one? I'm testing with ends_with "/" but after that... I've got nothing. I'm sure it's possible, but I honestly can't figure it out. This should be easy but it doesn't appear to be given the tools provided.
Any help?
- hooleylistCirrostratusHi neufpas,
set uri "/test/with/training/slash/" if {$uri ends_with "/"}{ log local0. "\$uri: $uri, stripped: [string range $uri 0 end-1]" }
- neufpas_66702NimbostratusThank you! I read through as much of the documentation as I could find and I never saw anything about being able to do "end-1". That should be documented somewhere.
- hooleylistCirrostratusIt's not described in detail in the string range section of the string man page but it's in the string index portion:
Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects