Core functions

Functions not in any module

Printing:

Messages to the caller

Regular expressions

Information:

Functions

Index:

eprintf

(eprintf fmt arg...) : like printf, except printing to stderr

print-info

(print-info fmt ...) : print an informational message to stderr (visible at hightened verbosity)

print-trace

(print-trace fmt ...) : print an informational message to stderr (visible at debug verbosity)

print-warning

(print-warning fmt args...) : print a warning to stderr (visible at normal verbosity).

With a string fmt, this prints the warning and returns the assembled message.

This function has a few variants, intended to be useful for manipulating a stream of warnings:

The warning is generated and stored at all verbosity levels, even quiet, but is not printed when we are being quiet.

printf

(printf fmt arg...) : format and print to stdout.

The format string argument can include a list of escapes, to indicate where the following arguments should be placed. These escapes can be:

regexp

(regexp "pattern" [flag ...]) : compile the pattern (extended RE syntax).

Flags:

regexp-match

Like regexp-match-positions, except that the returned list contains substrings taken from s, rather than their offsets.

regexp-match-positions

(regexp-match-positions re s (start 0)) : match the regular expression re once against the string s, returning a list of pairs, or #f if there is no match. The regexp can also be passed as a string, which will be compiled to a regexp on the fly.

The match found is that closest to the start of the string, but it is not anchored to the start (unless the pattern starts with "^").

The resulting list is a list of (start . end) pairs, where the start integer is the index, within s, of the start of the match, and end is the index of the character position one after the match. The first pair in the list is the match of the whole regexp; subsequent ones are the positions of any parenthesized subexpressions in the regexp. If a subexpression did not participate in the match, then the corresponding element in the list is returned as #f.

If start is given, it is the index at which to start matching. The offsets in the result are from the start of S, not from this start index.

If start is beyond the end of the string, then the match fails.

regexp-match-positions/multi

Like regexp-match-positions, except that the result is a list of non-overlapping position pairs indicating a sequence of matches of the regexp RE within S.

The :match-select keyword argument selects which of the possibly multiple results is passed on. If the RE contains submatches, then (as described in regexp-match-positions) the result will be a sequence of ranges. The default value of this keyword argument is car, which selects the first pair, indicating the whole matched string, but cadr, for example, will select the content of the first submatch, and values, as the identity function, will select the full set of matches.

Empty matches are handled like other matches, returning a zero-length range string, but the pattern is restricted from matching an empty sequence immediately after an empty match.

If start is beyond the end of the string, then the match fails, returning #f.

Examples:

> (regexp-match-positions/multi (regexp "x.") "12x4x6")
'((2 . 4) (4 . 6))      ; ie, '("x4" "x6")
> (regexp-match-positions/multi (regexp "x*") "12x4x6")
'((0 . 0) (1 . 1) (2 . 3) (3 . 3) (4 . 5) (5 . 5) (6 . 6)) ;ie, '("" "" "x" "" "x" "" "")

regexp-match/multi

This bears the same relationship to regexp-match as regexp-match-positions/multi bears to regexp-match-positions.

regexp-match?

(regexp-match? re s (start 0)) : match the regexp re against the string s, returning #t if it matches and #f if not.

The match is done between position start and the end of the string.

The regexp can be a regexp compiled with regexp, or a string.

regexp?

(regexp? x) : return #t if X is a regular expression

sprintf

(sprintf fmt arg...) : like printf, except returning a string

Norman
2026 August 02