chickadee » srfi-13 » string-contains

(string-contains s1 s2 [start1 end1 start2 end2]) -> integer or falseprocedure
(string-contains-ci s1 s2 [start1 end1 start2 end2]) -> integer or falseprocedure

Does string S1 contain string S2?

Return the index in S1 where S2 occurs as a substring, or false. 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 S1.

(string-contains "eek -- what a geek." "ee"
                 12 18) ; Searches "a geek"
    => 15

string-contains-ci is the case-insensitive variant. Case-insensitive comparison is done by case-folding characters with the operation

(char-downcase (char-upcase C))

where the two case-mapping operations are assumed to be 1-1, locale- and context-insensitive, and compatible with the 1-1 case mappings specified by Unicode's UnicodeData.txt table:

ftp://ftp.unicode.org/Public/UNIDATA/UnicodeData.txt

Comparison is simply done on individual code-points of the string.

The names of these procedures do not end with a question mark -- this is to indicate that they do not return a simple boolean (#t or #f). Rather, they return either false (#f) or an exact non-negative integer.