Next: srfi strings spec case-map, Previous: srfi strings spec prefix, Up: srfi strings spec [Index]
The following functions scan a string for the first character which:
The start and end arguments specify the beginning and end indices of the search; the search includes the start index, but not the end index. Be careful of “fencepost” considerations: when searching right–to–left, the first index considered is end-1, whereas when searching left–to–right, the first index considered is start.
That is, the start/end indices describe a same half–open
interval [start, end)
in these procedures that they
do in all the other SRFI-13 procedures.
Search through the string from the left, returning the index of the
first occurrence of a character matching the criterion; if no match is
found: return #f
.
Search through the string from the right, returning the index of the
first occurrence of a character matching the criterion; if no match is
found: return #f
.
Search the string from the left, returning the index of the first char
that does not satisfy the criterion; if no match is found:
return #f
.
E.g., to skip over initial whitespace, say:
(cond ((string-skip s char-set:whitespace) => (lambda (i) ...)) ;s[i] is not whitespace ...)
Search the string from the right, returning the index of the first char
that does not satisfy the criterion; if no match is found:
return #f
.
Return a count of the number of characters in str that satisfy the char/char-set/pred argument. If this argument is a procedure, it is applied to the character as a predicate; if it is a character set, the character is tested for membership; if it is a character, it is used in an equality test.
Return true if the string str1 contains string str2;
otherwise return #f
. Return the index in str1 where
str2 occurs as a substring. The optional start/end
indices restrict the operation to the indicated substrings.
The returned index is in the range [start1, end1)
. A
successful match must lie entirely in the [start1,
end1)
range of str1.
Example:
;; Searches "a geek" (string-contains "eek -- what a geek." "ee" 12 18) ⇒ 15
Case–insensitive variant.
Next: srfi strings spec case-map, Previous: srfi strings spec prefix, Up: srfi strings spec [Index]