chickadee » nutils » str-ndx-ls

str-ndx-lsprocedure
  • in - STR - search for indexes of this string
  • in - CHR - character to search for
  • in - STARTAT - (optional) index to start from, default is 0.
    • Note that with startat > 0, output indexes will not be different than 0 start. Decrement startat from results gives offset from startat.
  • in - FROMRIGHT? - (optional) if true, STARTAT and indexes are counted from end of string towards the beginning. The 0th character is at string-length - 1.
  • returns: list of indexes per input criteria or null list if none found.
 (import nutils)
 (define str "abc dws qthcd po9inmhy ecvhn")
 (str-ndx-ls str #\c) ;; => (2 11 24)
 (str-ndx-ls str #\c 0 #t) ;; (3 16 25) 
 (str-ndx-ls str #\c 5 #t) ;; (16 25) 
 (foreach* ((n '(16 25))) (- n 5)) ;; => (11 20)