next up previous contents
Next: About this document ... Up: QScheme Documentation Previous: 12 Virtual Machine   Contents

Subsections

13 QScheme libraries

13.1 Perl regular expressions - regex.so

The Perl regular expression module is a really good example of an extension module (a module that you can load while QScheme is running). This is an interesting example, because it dynamically adds a new syntactic token.

All the functions of this library will be added in the module regex.

The new syntaxic token #/regex/opts compiles a new regular expression. The options are:



Options Description
a anchored. Just like if re was enclosed between and $
i ignore case
s . matches also newlines
m multi-line
x extended
U ungreedy
X extra



Look at the pcre manual page for more informations.

The following functions deal with regular expressions:

(regex::isa? obj) -> <boolean>

Returns true when obj is a compiled regular expression.

(regex::match re string) -> <number> | #f

Returns the number of match found or #f if no match occurred.

(regex::sub n) -> <string> | #f

Returns the value of last nth sub-match.

(regex::$n) -> <string> | #f

Equivalent to (regex::sub n), where n is a number from 0 to 9.


next up previous contents
Next: About this document ... Up: QScheme Documentation Previous: 12 Virtual Machine   Contents
Daniel Crettol 2000-06-12