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 ...
hooleylist
May 26, 2011Cirrostratus
Hi neufpas,
You can use [string range $uri 0 end-1] to do this:
set uri "/test/with/training/slash/"
if {$uri ends_with "/"}{
log local0. "\$uri: $uri, stripped: [string range $uri 0 end-1]"
}
$uri: /test/with/training/slash/, stripped: /test/with/training/slash
Aaron
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