list-matches and fold-matches in ice-9 regexp are exported but not
documented.  They look pretty useful, I think I'll add some words
about them.

(And I think I'll try to clarify how you ask for both regexp/notbol
and regexp/noteol in the regexp-exec flags.  They're a logior if I'm
not mistaken.)


 -- Scheme Procedure: list-matches regexp str [flags]
     Return a list of match structures which are the non-overlapping
     matches of REGEXP in STR.  REGEXP can be either a string pattern
     or a compiled regexp.  FLAGS is as per `regexp-exec' above.

          (map match:substring (list-matches "[a-z]+" "abc 42 def 78"))
          => ("abc" "def")

 -- Scheme Procedure: fold-matches regexp str init proc [flags]
     Apply PROC to the non-overlapping matches of REGEXP in STR to
     build a result.  REGEXP can be either a string pattern or a
     compiled regexp.  FLAGS is as per `regexp-exec' above.

     PROC is called as `(PROC match prev)' where MATCH is a match
     structure and PREV is the previous return from PROC.  For the
     first call PREV is the given INIT parameter.  The final return
     from PROC is the return from `fold-matches'.

     For example to count matches,

          (fold-matches "[a-z][0-9]" "abc x1 def y2" 0
                        (lambda (m count)
                          (1+ count)))
          => 2


_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-devel

Reply via email to