Replace first match of re in s with the result of
(f (re-groups the-match)).
(defn replace-first-by
"Replace first match of re in s with the result of
(f (re-groups the-match))."
{:deprecated "1.2"}
[^Pattern re f ^String s]
(let [m (re-matcher re s)]
(let [buffer (StringBuffer.)]
(if (.find m)
(let [rep (f (re-groups m))]
(.appendReplacement m buffer rep)
(.appendTail m buffer)
(str buffer))))))
Comments top
No comments for replace-first-by. Log in to add a comment.