[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

10.7.7 String searching

Function: string-index s char/char-set/pred &optional start end
Function: string-index-right s char/char-set/pred &optional start end
[SRFI-13] Looks for the first element in a string s that matches char/char-set/pred, and returns its index. If char/char-set/pred is not found in s, returns #f. Optional start and end limit the range of s to search.

 
(string-index "Aloha oe" #\a) => 4
(string-index "Aloha oe" #[Aa]) => 0
(string-index "Aloha oe" #[\s]) => 5
(string-index "Aloha oe" char-lower-case?) => 1
(string-index "Aloha oe" #\o 3) => 6

See also the Gauche built-in procedure string-scan (6.10.7 String utilities), if you need speed over portability.

Function: string-skip s char/char-set/pred &optional start end
Function: string-skip-right s char/char-set/pred &optional start end
[SRFI-13] Looks for the first element that does not match char/char-set/pred and returns its index. If such element is not found, returns #f. Optional start and end limit the range of s to search.

Function: string-count s char/char-set/pred &optional start end
[SRFI-13] Counts the number of elements in s that matches char/char-set/pred. Optional start and end limit the range of s to search.

Function: string-contains s1 s2 &optional start1 end1 start2 end2
Function: string-contains-ci s1 s2 &optional start1 end1 start2 end2
[SRFI-13] Looks for a string s2 inside another string s1. If found, returns an index in s1 from where the maching string begins. Returns #f otherwise. Optional start1, end1, start2 and end2 limits the range of s1 and s2.

See also the Gauche built-in procedure string-scan (6.10.7 String utilities), if you need speed over portability.



This document was generated by Ken Dickey on November, 28 2002 using texi2html