A regular expression engine implementing SRFI 115 using a non-backtracking Thompson NFA algorithm.
Returns the matching result for the given named or indexed submatchn
, possibly as a list for a submatch-list, or
#f
if not matched.Returns the matching substring for the given named or indexed
submatch n
, or #f
if not matched.Returns the start index for the given named or indexed submatch
n
, or #f
if not matched.Returns the end index for the given named or indexed submatch
n
, or #f
if not matched.Convert an regexp-match result to a list of submatches, beginning
with the full match, using #f
for unmatched submatches.Convert an regexp-match result to a forest of submatches, beginning
with the full match, using #f
for unmatched submatches.Match the given regexp or SRE against the entire string and return
the match data on success. Returns #f
on failure.Match the given regexp or SRE against the entire string and return
the #t
on success. Returns #f
on failure.Search for the given regexp or SRE within string and return
the match data on success. Returns #f
on failure.Compile an sre
into a regexp.The fundamental regexp matching iterator. Repeatedly searches
str
for the regexp re
so long as a match can be found.
On each successful match, applies (kons
i
regexp-match
str
acc
)
where i
is the
index since the last match (beginning with
start
),regexp-match
is the resulting match, and
acc
is the result of the previous kons
application,
beginning with knil
. When no more matches can be found,
calls finish
with the same arguments, except that
regexp-match
is #f
.
By default finish
just returns acc
.Extracts all non-empty substrings of str
which match
re
between start
and end
as a list of strings.Splits str
into a list of strings separated by matches of
re
.Partitions str
into a list of non-empty strings
matching re
, interspersed with the unmatched portions
of the string. The first and every odd element is an unmatched
substring, which will be the empty string if re
matches
at the beginning of the string or end of the previous match. The
second and every even element will be a substring matching
re
. If the final match ends at the end of the string,
no trailing empty string will be included. Thus, in the
degenerate case where str
is the empty string, the
result is ("")
.Returns a new string replacing the count
th match of re
in str
the subst
, where the zero-indexed count
defaults to zero (i.e. the first match). If there are not
count
matches, returns the selected substring unmodified.
subst
can be a string, an integer or symbol indicating the
contents of a numbered or named submatch of re
,'pre
for the substring to the left of the match, or 'post
for
the substring to the right of the match.
The optional parameters start
and end
restrict both
the matching and the substitution, to the given indices, such that
the result is equivalent to omitting these parameters and
replacing on (substring str start end)
. As a convenience,
a value of #f
for end
is equivalent to
(string-length str)
.Equivalent to regexp-replace
, but replaces all occurrences
of re
in str
.