A custom iRule function which returns a substring named <string>, based on the values of the <skip_count> and <terminator> arguments.
Note the following:
  • The <skip_count> and <terminator> arguments are used in the same way as they are for the findstr command.
  • The <skip_count> argument is the index into <string> of the first character to be returned, where 0 indicates the first character of <string>.
  • The <terminator> argument can be either the subtring length or the substring terminating string.
  • If <terminator> is an integer, the returned string will include that many characters, or up to the end of the string, whichever is shorter.
  • If <terminator> is a string, the returned string will include characters up to but not including the first occurence of the string.
  • If <terminator> is a string which does not occur in the search space, from <skip_count> to the end of <string> is returned.
  • This command is equivalent to the Tcl string range command except that the value of the <terminator> argument may be either a character or a count.


substr <string> <skip_count> [<terminator>]

substr <string> <skip_count> [<terminator>]

  • Returns a sub-string from <string>, based on the values of the’<skip_count> and <terminator>* arguments.


  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]"  -- to be removed-- this does not really work for me v 11.5.4 and v 11.6.0

The above example logs the following: