[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

6.5 Regular Expressions

GNU Anubis supports two types of regular expressions: POSIX (both basic and extended), and Perl-style regular expressions. Among this, the former are always supported, whereas the support for the latter depends on the configuration settings at compile time. The default type of regular expressions is POSIX Extended.

A number of modifiers is provided to change the type of regular expressions. These are described in the following table.

:regex
:re
Indicates that the following pattern should be considered a regular expression. The default type for this expression is assumed.

:perl
:perlre
The regular expression is a Perl-style one.

:exact
:ex
Disables regular expression matching, all patterns will be matched as exact strings.

:scase
Enables case-sensitive comparison.

:icase
Enables case-insensitive comparison.

:basic
Switches to the POSIX Basic regular expression matching.

:extended
Switches to the POSIX Extended regular expression matching.

The special statement regex allows you to alter the default regular expression type. For example, the following statement

 
regex :perl :scase

sets the default regular expression types to Perl-style, case-sensitive. The settings of regex statement regard only those patterns that appear after it in the configuration file and have force until the next occurrence of the regex statement.

A couple of examples:

 
if header[Subject] :perlre "(?<=(?<!foo)bar)baz"
 ...
fi

This will match any Subject header whose value matches an occurrence of `baz' that is preceded by `bar' which in turn is not preceded by `foo'.
 
if header[Subject] :scase "^Re"

will match a Subject header whose value starts with `Re', but will not match it if it starts with `RE' or `re'.

When using POSIX regular expressions, the extended syntax is enabled by default. If you wish to use a basic regular expression, precede it with the :basic flag.

For the detailed description of POSIX regular expressions, See section `Regular Expression Library' in Regular Expression Library. For information about Perl-style regular expressions, refer to the Perl documentation.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

This document was generated by Wojciech Polak on December, 18 2004 using texi2html