On Fri 30 Dec 2011 16:12, Nala Ginrut <nalagin...@gmail.com> writes:

> So the previous discussion didn't make this proc put into Guile?
> Now that so many people interested in this topic. 

I think it would make a nice addition to (ice-9 regexp).  I don't think
we need to capture the delimiters though; some other function can do
that.

What do you think about this:

  (define* (regexp-split regex str #:optional (flags 0))
    (let ((ret (fold-matches
                regex str (cons '() 0)
                (lambda (m prev)
                  (let ((parts (car prev))
                        (start (cdr prev)))
                    (cons (cons (substring str start (match:start m))
                                parts)
                          (match:end m))))
                flags)))
      (reverse (cons (substring str (cdr ret)) (car ret)))))

Andy
-- 
http://wingolog.org/

Reply via email to