Modules index

# PCRE

This module provides regular expression functions. See the PCRE documentation for the syntax and options that PCRE provides.

Important functions and classes in the `PCRE` module are as follows:

`func compile(pattern):` Compiles the string `pattern` and returns a regular expression object.

### Regular expression objects

Regular expression objects have the following slots:

`func match(s, i := 0):` Attempts to match the regular expression against string `s`. `match` anchors its match to a particular position `i` which defaults to `0`. In other words, if the regular expression does not match at that position, it does not search through the string looking for another position to match at.

If the match succeeds, a match object is returned; otherwise the function fails.

`func search(s, i := 0):` Successively generates all match objects where the regular expression matches against the string `s`. The search starts at position `i`, which defaults to `0`.

For each successful search, a match object is generated; when no more matches are found, the function fails.

### Match objects

Match objects have the following slots:

`func get(group_num):` Returns the slice of the string matched by the group numbered `group_num`. Groups are specified within a regular expression by use of parentheses, and are numbered starting from 1. There is an implicit group 0 which returns the entire string matched by the regular expression.

Note that this effect can also be achieved via the slice notation i.e. `match.get(X)` is equivalent to `match[X]`.

`func get_indexes(group_num):` Returns the start and end indices as a list `[start, end]` of the string matched by the group numbered `group_num`. Groups are specified within a regular expression by use of parentheses, and are numbered starting from 1. There is an implicit group 0 which returns the start and end indices of the entire string matched by the regular expression.

cvd_to_html ©2006-2007 Laurence Tratt