[plt-scheme] pregexp-match-positions

From: Robert Nikander (nikander at nc.rr.com)
Date: Mon Oct 29 16:26:30 EDT 2007

On Oct 29, 2007, at 3:40 PM, Paulo J. Matos wrote:
> I was expecting for pregexp-match-positions to return a list with all
> position pairs with a match. It seems, however, that it only returns
> the first. If this is the case, why not return just a pair instead of
> returning  a list with the pair. Am I missing something?
>
> The example:
>> (pregexp-match-positions "\\[\\s*\\d+\\s+[[:alnum:]]+\\s*\\]" "[1  
>> define] [2 define]")
> ((0 . 10))
>
> On the one hand if it returns all there's a missing pair. It if
> returns just one, why not return (0 . 10)?


If you have groups within your regexp, you get a list with more than  
one pair.  Eg:

(pregexp-match-positions "a(a)" "aa") => ((0 . 2) (1 . 2))

Rob


Posted on the users mailing list.