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>
(regex::match re string) -> <number> | #f
(regex::sub n) -> <string> | #f
(regex::$n) -> <string> | #f