The Modular DocBook Stylesheets | ||
---|---|---|
Prev | DSSSL Library | Next |
(match-split string target)
Splits string at every occurance of target and returns the result as a list. Note that match-split returns the occurances of target in the list of tokens.
The string to split.
The string which is a delimiter between tokens
"this is a test" split at "is" returns ("th" "is" " " "is" " a test")
Norman Walsh, <norm@berkshire.net>
(define (match-split string target) ;; Splits string at target and returns the resulting list of tokens (let loop ((result '()) (current "") (rest string)) (if (< (string-length rest) (string-length target)) (append result (if (equal? (string-append current rest) "") '() (list (string-append current rest)))) (if (equal? target (substring rest 0 (string-length target))) (loop (append result (if (equal? current "") '() (list current)) (list target)) "" (substring rest (string-length target) (string-length rest))) (loop result (string-append current (substring rest 0 1)) (substring rest 1 (string-length rest)))))))
Prev | Home | Next |
match-split-string-list | Up | match-substitute-sosofo |
Copyright © 1997, 1998 Norman Walsh