[plt-scheme] pregexp.ss multiple matches (something)*

From: Cyprien Nicolas (c.nicolas at gmail.com)
Date: Sun Oct 7 17:04:41 EDT 2007


I'm trying to make multiples matches using pregexp-match within
pregexp.ss library.

I would like to match the same pattern n times and to keep all the
results as a list.

I don't know if my explanation is clear, so here is an example with
comma-separated values

(require (lib "pregexp.ss"))
(pregexp-match "^(\\d+)(?:[., ](\\d+))*$" "123,456,789,010")

The result is ("123,456,789" "123" "010")

And I would like to get ("123,456,789" "123" "456" "789" "010")

I only get the last matched text.
That behavior is not explained in the documention, is that a bug ?

I that example it will be easier to use pregexp-split, but the text I
want to match is a little more complex than CSV.

Cyprien Nicolas

Posted on the users mailing list.