Building Regular Expressions

Most regular expressions that you use with Webtrends are very simple, often consisting of a few basic elements.

Matching Order Rules

There are several rules involved with how regular expression matching occurs:

Example 1

To match all of the values that begin with couch, use the following regular expression:

^couch

Example 2

To match all of the values that end with couch, use the following regular expression:

couch$

Example 3

To match all values containing either couch or chair, including blue_chair, chair_55, and big_couch_55, use the following regular expression:

couch|chair

Example 4

To match a qualifying page URL that contains any product news HTML pages from January, February, or March, use the following regular expression:

/product/news/(jan|feb|mar)/.+\.htm

This expression matches any item such as a URL containing the string /product/news/, followed by either jan, feb, or mar, followed by / and one or more of any character (.+), followed by .htm.

This expression matches the following URLs:

/product/news/jan/chair.htm /product/news/feb/mirror.htm /product/news/mar/couch.htm /product/news/jan/table.htm /product/news/jan/table.html

but not these URLs:

/product/news/jan/chair.asp /product/news/jan/chair.gif /product/news/apr/chair.htm

Example 5

To match all URLs indicating that an individual product in the furniture category has been registered, use the following regular expression

^/product/furniture/.+/register.htm

This expression matches all URLs that begin with /product/furniture/, followed by one or more occurrences of any character, followed by /register.htm.

This expression matches the following URLs:

/product/furniture/couch/register.htm /product/furniture/chair/register.htm /product/furniture/couch/register.htm /product/furniture/bedroom/armoire/register.htm

but not this URL:

/product/furniture/index.htm