Skip to content
Walt K edited this page Aug 1, 2018 · 2 revisions

string-index return the index of the first occurrence of char in str. Returns #f if char is not present.

Parameter Description
str Input string
a-char The character searched for
comp Optional: The comparison operator, if not specified it is char=?

Examples

Example 1: Find first position of "(" bracket in a string.

> (define str "[(a,v,b)]")
> (string-index str #\()

Example 2: Find first position of an x or X in the string.

> (define str "A X B X C")
> (string-index str #\x char-ci=?)
Clone this wiki locally