ADC

Operations for regular expressions

The following table describes the operators that work with regular expressions. The operation performed by a regular expression operator in a given default syntax expression depends on whether the expression prefix identifies text or HTTP headers. Operations that evaluate headers override any text-based operations for all instances of the specified header type. When you use an operator, replace <text> with the default syntax expression prefix that you want to configure for identifying text.

Regular Expression Operation Description
.BEFORE_REGEX() Selects the text that precedes the string that matches the argument. If the regular expression does not match any data in the target, the expression returns a text object of length 0. The following expression selects the string "text" from "text/plain". http.res.header("content-type").before_regex(re#/#)
.AFTER_REGEX() Selects the text that follows the string that matches the argument. If the regular expression does not match any text in the target, the expression returns a text object of length 0. The following expression extracts "Example" from "myExample": http.req.header("etag").after_regex(re/my/)
.REGEX_SELECT() Selects a string that matches the argument. If the regular expression does not match the target, a text object of length 0 is returned. The following example extracts the string "NS-CACHE-9.0: 90" from a Via header: http.req.header("via").regex_select(re!NS-CACHE-\d.\d:\s*\d{1,3}!)
.REGEX_MATCH() Returns TRUE if the target matches a argument of up to 1499 characters. The regular expression must be of the following format: reregular expression< delimiter> Both delimiters must be the same. Additionally, the regular expression must conform to the Perl-compatible (PCRE) regular expression library syntax. For more information, go to http://www.pcre.org/pcre.txt. In particular, see the pcrepattern man page. However, note the following: Back-references are not allowed. Recursive regular expressions are not recommended. The dot metacharacter also matches the newline character. The Unicode character set is not supported. SET_TEXT_MODE(IGNORECASE) overrides the (?i) internal option specified in the regular expression. The following are examples: http.req.hostname.regex_match(re/[[:alpha:]]+(abc){2,3}/) and http.req.url.set_text_mode(urlencoded).regex_match(re#(a*b+c*)#) The following example matches ab and aB: http.req.url.regex_match(re/a(?i)b/) The following example matches ab, aB, Ab and AB: http.req.url.set_text_mode(ignorecase).regex_match(re/ab/) The following example performs a case-insensitive, multiline match in which the dot meta-character also matches a newline character: http.req.body.regex_match(re/(?ixm) (^ab (.*) cd$) /)
Operations for regular expressions