giorgio_32761
Dec 21, 2018Nimbostratus
URI Manipulation
Hi, I would like to extract part of a URI, from the 5th "/" to the end, for example:
/string1/string2/string3/string4/something/seomethingelse/
should become:
/something/somethingelse
I cannot use one of the string as delimiter, since they change, but for sure they are always 4
I found that this works, but I wonder if there is some solution more "efficient":
set uri [HTTP::uri]
set fields [split $uri "/"]
set num_fields [llength $fields]
set str1 [getfield [HTTP::uri] "/" 2]
set str2 [getfield [HTTP::uri] "/" 3]
set str3 [getfield [HTTP::uri] "/" 4]
set str4 [getfield [HTTP::uri] "/" 5] set newuri ""
set finaluri ""
for {set x 5} {$x<$num_fields} {incr x} {
set newuri /[lindex $fields $x]
set finaluri $finaluri$newuri
Thanks