ltm rule command substr
iRule(1) BIG-IP TMSH Manual iRule(1)
substr
Returns a substring from a string.
SYNOPSIS
substr STRING SKIP_COUNT (TERMINATOR)?
DESCRIPTION
A custom iRule function which returns a substring named , based
on the values of the and arguments. Note the
following:
* The and arguments are used in the same
way as they are for the findstr command.
* The argument is the index into of the first
character to be returned, where 0 indicates the first character of
.
* The argument can be either the subtring length or the
substring terminating string.
* If is an integer, the returned string will include
that many characters, or up to the end of the string, whichever is
shorter.
* If is a string, the returned string will include
characters up to but not including the first occurence of the
string.
* If is a string which does not occur in the search
space, from to the end of is returned.
* This command is equivalent to the Tcl string range command except
that the value of the argument may be either a
character or a count.
Syntax
substr []
* Returns a sub-string from , based on the values of
the' and * arguments.
RETURN VALUE
VALID DURING
ANY_EVENT, GLOBAL_GTM, INFORMATIONAL_COMMAND, STRING_FUNCTION
EXAMPLES
when HTTP_REQUEST {
set uri [substr $uri 1 "?"]
log local0. "Uri Part = $uri"
}
log "[substr "abcdefghijklm" 2 "x"]"
log "[substr "abcdefghijklm" 2 "gh"]"
log "[substr "abcdefghijklm" 2 4]"
log "[substr "abcdefghijklm" 2 20]"
log "[substr "abcdefghijklm" 2 0]"
The above example logs the following:
cdefghijklm
cdef
cdef
cdefghijklm
cdefghijklm
HINTS
SEE ALSO
CHANGE LOG
@BIGIP-9.0.0 --First introduced the command.
BIG-IP 2017-01-31 iRule(1)