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