164 Citrix NetScaler Policy Configuration and Reference Guide
show policy patset pattern_name
Where patternName is the name of a pattern that you want to view.
4. Configure the pattern set as part of an expression.
For example, you can configure it in a policy rule. For more information,
see “Creating or Modifying an Advanced Policy,” on page 14. Following is
an example that uses the pattern set myPatSet, and returns TRUE if the
value of the HTTP header named myHeader contains any of the strings that
you defined earlier in this procedure:
add cache policy testPatSet -rule
http.req.header("myHeader").contains_index("myPatSet1") -
action cache
Matching Text With a Pattern
In addition to matching text with a set of patterns, you can define an arbitrary
pattern that uses wildcards. In most types of expressions, you should avoid using
wildcards. For example, the following expression is legal but may have
unexpected results:
http.req.url.path.contains("/*.jpeg")
Note that this expression would not, for example, match the following URL:
http://10.102.58.201/icon.jpeg
Following is an example of a regular expression that matches a URL that contains
the file name suffix, “.jpeg”:
http.req.url.regex_match(re/*.jpeg/)
In general, for simple pattern matching, it is preferable to use the CONTAINS or
EQ operation to perform a partial string match. For example, the following
expressions check the file name extension:
http.req.url.suffix.contains("jpeg")
http.req.url.suffix.eq("jpeg")
However, if you need to match more complex patterns in text, you can define a
regular expression. For example, the following example selects "text" from "text/
plain":
http.res.header("content-type").before_regex(re#/#)
The NetScaler supports regular expression syntax as described on the following
Web s ite :
http://www.pcre.org/pcre.txt
For an introduction to regular expressions, see the following URLs: