Next: , Previous: , Up: Modules   [Contents][Index]


5.12 Pcre

The pcre module provides a matching strategy using Perl-compatible regular expressions. The module is loaded using a simple statement:

load-module pcre;

The strategy has the same name as the module and is reflected in the server’s HELP output as shown below:

pcre  "Match using Perl-compatible regular expressions"

The headword argument to the pcre MATCH statement should be a valid Perl regular expression. It can optionally be enclosed in a pair of slashes, in which case one or more of the following flags can appear after the closing slash:

a

The regexp is anchored, that is, it is constrained to match only at the first matching point in the string that is being searched.

e

Ignore whitespace and ‘#’ comments in the expression.

i

Ignore case when matching.

G

Inverts the greediness of the quantifiers so that they are not greedy by default, but become greedy if followed by ‘?’. The same can also be achieved by setting the ‘(?U)’ option within the pattern.

Any of these flags can also be used in reverted case, which also reverts its meaning. For example, ‘I’ means case-sensitive matching.

Here is an example of using this strategy in a dico session:

MATCH ! pcre "/\\stext/i"