1.2.0 permalink Arrow_down_16x16

replace-first-by

clojure.contrib.string

  • (replace-first-by re f s)
Replace first match of re in s with the result of
(f (re-groups the-match)).

0 Examples top

Log in to add / edit an example.

See Also top

Log in to add a see also.

Plus_12x12 Minus_12x12 Source clojure/contrib/string.clj:195 top

(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))))))
Vars in clojure.contrib.string/replace-first-by: defn let str
Used in 0 other vars

Comments top

No comments for replace-first-by. Log in to add a comment.