|
From: | Alex Shinn |
Subject: | Re: [Chicken-users] irregex-replace return value |
Date: | Mon, 3 Mar 2014 18:00:59 +0900 |
While writing my own version of irregex-replace can be (hopefully) an enjoyable
6-line coding experience (btw, irregex-apply-match is not documented):
(define (my-own-irregex-replace irx s . o)
(let ((m (irregex-search irx s)))
(and m (string-append
(substring s 0 (irregex-match-start-index m 0))
(apply string-append (reverse (irregex-apply-match m o)))
(substring s (irregex-match-end-index m 0) (string-length s))))))
writing a customized version of irregex-replace/all means writing a real
non-elementary program.
#;3> (my-irregex-replace-all '(+ digit) "one 1 two 22 three 333" "?")
"one ? two ? three ?"
3
; 2 values
[Prev in Thread] | Current Thread | [Next in Thread] |