www.delorie.com/gnu/docs/guile/guile_194.html   search  
 
Buy GNU books!


Guile Reference Manual

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

21.4.8 String Searching

When searching for the index of a character in a string, these procedures can be used.

Scheme Procedure: string-index str chr [frm [to]]
C Function: scm_string_index (str, chr, frm, to)
Return the index of the first occurrence of chr in str. The optional integer arguments frm and to limit the search to a portion of the string. This procedure essentially implements the index or strchr functions from the C library.

 
(string-index "weiner" #\e)
=> 1

(string-index "weiner" #\e 2)
=> 4

(string-index "weiner" #\e 2 4)
=> #f

Scheme Procedure: string-rindex str chr [frm [to]]
C Function: scm_string_rindex (str, chr, frm, to)
Like string-index, but search from the right of the string rather than from the left. This procedure essentially implements the rindex or strrchr functions from the C library.

 
(string-rindex "weiner" #\e)
=> 4

(string-rindex "weiner" #\e 2 4)
=> #f

(string-rindex "weiner" #\e 2 5)
=> 4


  webmaster     delorie software   privacy  
  Copyright 2003   by The Free Software Foundation     Updated Jun 2003