(eval-string
str
[err-display err-result
])
PROCEDURE
Reads and evaluates S-expressions from the string str
, returning
a result for each expression. Note that if str
contains only
whitespace and comments, zero values are returned, while if str
contains two expressions, two values are returned.
If err-display
is not #f
(the default), then errors are
caught and err-display
is used as the error display handler. If
err-result
is specified, it must be a thunk
that returns a value to be returned when an error is caught;
otherwise, #f
is returned when an error is caught.
Prints expr
into a string and returns the string.
(read-from-string
str
[err-display err-result
])
PROCEDURE
Reads the first S-expression from the string str
and returns it.
The err-display
and err-result
are as in eval-str
.
(read-from-string-all
str
[err-display err-result
])
PROCEDURE
Reads all S-expressions from the string str
and returns them in a list.
The err-display
and err-result
are as in eval-str
.
(regexp-match*
pattern str
[start-k end-k
])
PROCEDURE
Like regexp-match
(see section 10 in PLT MzScheme: Language Manual), but the result is
a list of strings corresponding to a sequence of matches of
pattern
in str
. (Unlike regexp-match
, results
for parenthesized sub-patterns in pattern
are not returned.)
If pattern
matches a zero-length string along the way, the
exn:user
exception is raised.
If str
contains no matches (in the range start
to
end
), null
is returned. Otherwise, each string in the
resulting list is a distinct substring of str
that matches
pattern
.
(regexp-match-exact?
pattern str
)
PROCEDURE
This procedure is like MzScheme's built-in regexp-match
(see
section 10 in PLT MzScheme: Language Manual), but the result is always #t
or
#f
; #t
is only returned when the entire string
str
matches pattern
.
(regexp-match-positions*
pattern str
[start-k end-k
])
PROCEDURE
Like regexp-match-positions
(see section 10 in PLT MzScheme: Language Manual), but the
result is a list of integer pairs corresponding to a sequence of
matches of pattern
in str
. (Unlike
regexp-match-positions
, results for parenthesized
sub-patterns in pattern
are not returned.) If pattern
matches a zero-length string along the way, the exn:user
exception is raised.
If str
contains no matches, null
is returned.
(regexp-quote
str
[case-sensitive?
])
PROCEDURE
Produces a string suitable for use with
(see
section 10 in PLT MzScheme: Language Manual) to match the literal sequence of characters in
regexp
str
. If case-sensitive?
is true, the resulting regexp
matches letters in str
case-insensitively, otherwise (and by
default) it matches case-sensitively.
(regexp-replace-quote
str
)
PROCEDURE
Produces a string suitable for use as the third argument to
(see section 10 in PLT MzScheme: Language Manual), to insert the
literal sequence of characters in regexp-replace
str
as a
replacement. Concretely, every backslash in str
is protected by
a quoting backslash.
(regexp-split
pattern str
[start-k end-k
])
PROCEDURE
The complement of regexp-match*
(see above): the result is a
list of sub-strings in str
that are separated by matches to
pattern
; adjacent matches are separated with ""
. If
pattern
matches a zero-length string along the way, the
exn:user
exception is raised.
If str
contains no matches (in the range start
to
end
), the result will be a list containing str
(from
start
to end
). If a match occurs at the beginning of
str
(at start
), the resulting list will start with an
empty string, and if a match occurs at the end (at end
), the
list will end with an empty string.
(string-lowercase!
str
)
PROCEDURE
Destructively changes str
to contain only lowercase characters.
(string-uppercase!
str
)
PROCEDURE
Destructively changes str
to contain only uppercase characters.