Replaces all matches of re in s with the result of
(f (re-groups the-match)).
(defn replace-by
"Replaces all matches of re in s with the result of
(f (re-groups the-match))."
{:deprecated "1.2"}
[re f ^String s]
(let [m (re-matcher re s)]
(let [buffer (StringBuffer. (.length s))]
(loop []
(if (.find m)
(do (.appendReplacement m buffer (f (re-groups m)))
(recur))
(do (.appendTail m buffer)
(.toString buffer)))))))
Comments top
No comments for replace-by. Log in to add a comment.