By default, Guile supports POSIX extended regular expressions. That means that the characters `(', `)', `+' and `?' are special, and must be escaped if you wish to match the literal characters.
This regular expression interface was modeled after that implemented by SCSH, the Scheme Shell. It is intended to be upwardly compatible with SCSH regular expressions.
string-match returns a match structure which
describes what, if anything, was matched by the regular
expression. See section Match Structures. If str does not match
pattern at all,
string-match is called, it must compile its
pattern argument into a regular expression structure. This
operation is expensive, which makes
string-match inefficient if
the same regular expression is used several times (for example, in a
loop). For better performance, you can compile a regular expression in
advance and then match strings against the compiled regexp.
The flag arguments change the behavior of the compiled regexp. The following flags may be supplied:
regexp/extendedflags, the one which comes last will override the earlier one.
str. If the optional integer start argument is provided, begin matching from that position in the string. Return a match structure describing the results of the match, or
#fif no match could be found.
#tif obj is a compiled regular expression, or
Regular expressions are commonly used to find patterns in one string and replace them with the contents of another string.
port may be
#f, in which case nothing is written; instead,
regexp-substitute constructs a string from the specified
items and returns that.
regexp-substitute, but can be used to perform global substitutions on str. Instead of taking a match structure as an argument,
regexp-substitute/globaltakes two string arguments: a regexp string describing a regular expression, and a target string which should be matched against this regular expression.
Each item behaves as in regexp-substitute, with the following exceptions:
regexp-substitute/globalto recurse on the unmatched portion of str. This must be supplied in order to perform global search-and-replace on str; if it is not present among the items, then
regexp-substitute/globalwill return after processing a single match.
Go to the first, previous, next, last section, table of contents.