string index - part-cw/lambdanative GitHub Wiki
(string-index str a-char . comp)
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=?)