(require '[rewrite-indented.zip :as z])
;; => nil
(-> (z/of-string "foo\n TARGET\n bar")
(z/find-next-string #(= "TARGET" %))
(z/update (constantly "hello"))
(z/root-string))
;; => "foo\n hello\n bar"
(loop [zloc (z/of-string "first\n TARGET\n foo\nsecond\n TARGET\n bar")]
(if-let [zloc (z/find-next-string zloc #(= "TARGET" %))]
(recur
(cond-> zloc
(z/find-ancestor-string zloc #(= "second" %))
(z/update (constantly "hello"))
:always
(z/next)))
(z/root-string zloc)))
;; => "first\n TARGET\n foo\nsecond\n hello\n bar"