Regular Expressions

Regular expressions are a powerful method for defining a class of strings (strings are sequences of characters; for instance, a filename is a string, and so is a log entry). Sawmill 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.

In brief, a regular expression is a pattern, which is essentially the string to match, plus special characters which match classes of string, plus operators to combine them. 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.


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.