On 30 December 2011 16:46, Nala Ginrut <
address@hidden> wrote:
> hi Daniel! Very glad to see your reply.
> 1. I also think the order: (regexp str) is strange. But it's according to
> python version.
> And I think the 'string-match' also put regexp before str. Anyway, that's an
> easy mend.
`regexp string' is also the same order as `list-matches' and
`fold-matches'. Probably best to keep it that way if this is in the
regex module.
>> I would like to see your version support the Python semantics [1]:
>>
>> > If capturing parentheses are used in pattern, then the text of
>> > all groups in the pattern are also returned as part of the resulting
>> > list.
>> [...]
>> > >>> re.split('\W+', 'Words, words, words.')
>> > ['Words', 'words', 'words', '']
>> > >>> re.split('(\W+)', 'Words, words, words.')
>> > ['Words', ', ', 'words', ', ', 'words', '.', '']
>>
>> >>> re.split('((,)?\W+?)', 'Words, words, words.')
>> ['Words', ', ', ',', 'words', ', ', ',', 'words', '.', None, '']
FYI this can be achieved by changing the inner part to:
(let* ...
(s (substring string start end))
(groups (map (lambda (n) (match:substring m n))
(iota (1- (match:count m)) 1))))
(list `(,@ll ,s ,@groups) (match:end m) tail)))
Note: using srfi-1 iota