A cursor-oriented string library. Provides efficient string utilities for implementations with or without fast random-access strings.
The procedures below are similar to those in SRFI 13 or other string libraries, except instead of receiving and returning character indexes they use opaque string cursors.
Returns true iff str
is equal to the empty string ""
.
Returns true iff check
is true for any character in
str
. check
can be a procedure, char (to test for
char=?
equivalence) or char-set (to test for
char-set-contains?
). Always returns false if str
is
empty.
Returns true iff check
is true for every character in
str
. check
can be a procedure, char or char-set as in
string-any
. Always returns true if str
is empty.
Returns a cursor pointing to the first position from the left in
string for which check
is true. check
can be a
procedure, char or char-set as in string-any
. The
optional cursors start
and end
can specify a substring
to search, and default to the whole string. Returns a cursor just
past the end of str
if no character matches.
As above, ignoring the position and returning true iff any character matches.
As string-find
, but returns the position of the first
character from the right of str
. If no character matches,
returns a string cursor pointing just before start
.
As string-find
, but inverts the check, returning the
position of the first character which doesn't match.
As string-find-right
, but inverts the check, returning
the position of the first character which doesn't match.
Concatenates the list-of-strings
and return the result as a
single string. If separator
is provided it is inserted
between each pair of strings.
Split str
into a list of substrings separated by pred
,
which defaults to #\space
. Multiple adjacent characters
which satisy pred
will result in empty strings in the list.
If the optional limit
is provided, splits into at most that
many substrings starting from the left.
Returns a copy of the string str
with all characters
matching pred
(default #\space
) removed from the
left.
Returns a copy of the string str
with all characters
matching pred
(default #\space
) removed from the
right.
Returns a copy of the string str
with all characters
matching pred
(default #\space
) removed from both
sides.
Returns two values: the first cursors from the left in
prefix
and in str
where the two strings don't match.
Returns two values: the first cursors from the right in
prefix
and in str
where the two strings don't match.
Returns true iff prefix
is a prefix of str
.
Returns true iff suffix
is a suffix of str
.
The fundamental string iterator. Calls kons
on each
character of str
and an accumulator, starting with
knil
. If multiple strings are provided, calls kons
on
the corresponding characters of all strings, with the accumulator
as the final argument, and terminates when the shortest string
runs out.
Equivalent to string-fold
, but iterates over str
from right to left.
Returns a new string composed of applying the procedure proc
to every character in string
.
Apply proc
to every character in str
in order and
discard the result.
Count the number of characters in str
for which check
is true.
Returns a cursor pointing to the first position in the string
s1
where s2
occurs, or #f
if there is no such
match.
Partial application of string-contains
. Return a
procedure of one argument, a string, which runs
(string-contains str
.needle
)
Return a copy of string s
with all 26 upper-case ASCII
characters mapped to their corresponding 26 lower-case ASCII
characters.
Return a copy of string s
with all 26 lower-case ASCII
characters mapped to their corresponding 26 upper-case ASCII
characters.
Returns the substring of str
between i
(inclusive) and
optional j
(exclusive), which defaults to the end of the
string.
Returns the character of str
at position i
.
Returns a string cursor pointing to the start of str
.
Returns a string cursor pointing just past the end of str
.
Returns a string cursor to the character in str
just after
the cursor i
.
Returns a string cursor to the character in str
just before
the cursor i
.
String cursor comparators.