Procedures that perform regular-expression match and search accept
standardized arguments. Regexp is the regular expression; it is a
string. String is the string being matched or searched.
Procedures that operate on substrings also accept start and
end index arguments with the usual meaning. The optional argument
case-fold? says whether the match/search is case-sensitive; if
#f, it is case-sensitive, otherwise it is
case-insensitive. The optional argument syntax-table is a
character syntax table that defines the character syntax, such as which
characters are legal word constituents. This feature is primarily for
Edwin, so character syntax tables will not be documented here.
#f for (or omitting) syntax-table will select the
default character syntax, equivalent to Edwin's
These procedures match regexp against the respective string or substring, returning
#ffor no match, or a set of match registers (see below) if the match succeeds. Here is an example showing how to extract the matched substring:(let ((r (re-substring-match regexp string start end))) (and r (substring string start (re-match-end-index 0 r))))
Searches string for the leftmost substring matching regexp. Returns a set of match registers (see below) if the search is successful, or
#fif it is unsuccessful.
re-substring-search-forwardlimits its search to the specified substring of string;
re-string-search-forwardsearches all of string.
Searches string for the rightmost substring matching regexp. Returns a set of match registers (see below) if the search is successful, or
#fif it is unsuccessful.
re-substring-search-backwardlimits its search to the specified substring of string;
re-string-search-backwardsearches all of string.
When a successful match or search occurs, the above procedures return a
set of match registers. The match registers are a set of index
registers that record indexes into the matched string. Each index
register corresponds to an instance of the regular-expression grouping
operator `\(', and records the start index (inclusive) and end
index (exclusive) of the matched group. These registers are numbered
9, corresponding left-to-right to the grouping
operators in the expression. Additionally, register
corresponds to the entire substring matching the regular expression.
N must be an exact integer between
9inclusive. Registers must be a match-registers object as returned by one of the regular-expression match or search procedures above.
re-match-start-indexreturns the start index of the corresponding regular-expression register, and
re-match-end-indexreturns the corresponding end index.
Registers must be a match-registers object as returned by one of the regular-expression match or search procedures above. String must be the string that was passed as an argument to the procedure that returned registers. N must be an exact integer between
9inclusive. If the matched regular expression contained m grouping operators, then the value of this procedure is undefined for n strictly greater than m.
This procedure extracts the substring corresponding to the match register specified by registers and n. This is equivalent to the following expression:(substring string (re-match-start-index n registers) (re-match-end-index n registers))