* doc list-matches, fold-matches
@ 2005-04-18 22:15 Kevin Ryde
0 siblings, 0 replies; only message in thread
From: Kevin Ryde @ 2005-04-18 22:15 UTC (permalink / raw)
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
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2005-04-18 22:15 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-04-18 22:15 doc list-matches, fold-matches Kevin Ryde
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).