{= include("docs.util"); start_docs_page(docs.technical_manual.page_titles.regexp); =}

Regular Expressions

A regular expression, often called a pattern, is simply a text string that describes or matches a set of strings, according to certain syntax rules. Strings are sequences of characters; for instance, a filename is a string, and so is a log entry. The pattern is made up of the string to match, plus special characters which match classes of string, plus operators to combine them. $PRODUCT_NAME uses regular expressions in many places, including:

You can also use wildcard expressions in these cases, using * to match any string of characters, or ? to match any single character (for instance, *.gif to match anything ending with .gif, or Jan/??/2000 to match any date in January, 2000). Wildcard expressions are easier to use than regular expressions, but are not nearly as powerful.

Regular expressions can be extremely complex, and it is beyond the scope of this manual to describe them in full detail. See Yahoo's Regular Expression Category for more in-depth information; this link leads to Yahoo's web pages, and so requires a live internet connection.

Here are the simplest rules:

The list goes on, but is too large to include here in complete form. See the Yahoo link above. Some examples:

As you can see, regular expressions are extremely powerful; a pattern can be devised to match almost any conceivable need.

NOTE ABOUT FILTERS

Both regular expression pattern filters and DOS-style pattern filters are necessary in some cases, but they should be avoided when possible because pattern filters can be considerably slower than the simpler filter types like "ends with" or "contains". If you can create a filter without patterns, do--your log processing will be faster.

{= end_docs_page() =}