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

Subsections

12. QScheme libraries

12.1 Perl regular expressions - regex.so

The Perl regular expression module is a really good example of an extension module, ie you can dynmically load this module by using the load-library function. This is an interesting example, because it dynamically adds a new syntaxic 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. Options are:



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



Look at the pcre manual page for more informations.

The following functions deals with regular expression:

(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 occured.

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

Return the value of last nth submatch

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

Where n is a number from 0 to 9. Equivalent to the (regex::sub n)


next up previous contents
Next: About this document ... Up: QScheme Documentation Previous: 11. Virtual Machine   Contents
Daniel Crettol
1999-07-19