contains

Description

Tests if one string contains another string

Syntax

<string1> contains <string2>

<string1> contains <string2>

  • Tests if string2 is contained within string1 using a case-sensitive search.

The above example is equivalent to the TCL string match command:
string match *string2* string1

Note: The ‘contains’ operator does not support wildcards. It simply compares two strings to see if the second is a substring of the first.

Examples

when HTTP_REQUEST {
  # case sensitive
  if { [HTTP::uri] contains "aol" } {
     pool aol_pool
  } else {
     pool all_pool
  }

  # case insensitive
  if { [string tolower [HTTP::uri]] contains "aol" } {
     pool aol_pool
  } else {
     pool all_pool
  }
}