Skip to content
Chris Petersen edited this page Oct 16, 2014 · 2 revisions

string-index return the index of the first occurrence of char in str.

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