Thanks for your response. This looks like it works as expected. If you don’t mind (I need to learn regex much better) can you explain what exactly you are doing with this:
[findstr [string tolower [HTTP::uri]] “/sec+test/” 10 “.htm”] - finds the part of the string that STARTS WITH “/sec+test/”, skips 10 characters (the length of “/sec+test/”), and ends before “.htm”. If the URI was “/sec+test/foo/bar.htm”, then this would return “foo/bar”.
[split [findstr [string tolower [HTTP::uri]] “/sec+test/” 10 “.htm”] “/”] - splits the returned string into a list, based on the delimiter character “/”. in the above string this would produce a list of two values: “foo” and “bar”.
[lindex [split [findstr [string tolower [HTTP::uri]] “/sec+test/” 10 “.htm”] “/”] 1] - list extracts the second element from the previously returned list. Lists start with a 0 (zero) index, so the second element is 1. This then returns “bar”.
While findstr is an efficient and simple way to extract text from a given string, I must concede that Nitass’ scan example is more elegant. If I may Nitass:
{/SEC+TEST/%*[^/]/%[^.].htm}
The percent sign in the TCL scan command is a “conversion specifier”. If you include the * star character after the % it means that you DO NOT want to include the next values in the scan. So %*[^/] means to ignore the next set of values that do not (^ means NOT) contain a “/” character - so don’t include the value after “/SEC+TEST/” and before the next “/”. The next % character and brackets means to capture the next set of values that do not contain a “.” period character, so everything after the last “/” and before “.htm”.