diff --git a/src/clj/com/rpl/specter.cljc b/src/clj/com/rpl/specter.cljc index 0339c1f..5f6e6e4 100644 --- a/src/clj/com/rpl/specter.cljc +++ b/src/clj/com/rpl/specter.cljc @@ -1068,6 +1068,13 @@ (swap! structure next-fn) structure))) +(defnav regex-nav [re] + (select* [this structure next-fn] + (doseqres NONE [s (re-seq re structure)] + (next-fn s))) + (transform* [this structure next-fn] + (clojure.string/replace structure re next-fn))) + (defdynamicnav selected? "Filters the current value based on whether a path finds anything. e.g. (selected? :vals ALL even?) keeps the current element only if an @@ -1172,7 +1179,7 @@ (extend-type #?(:clj java.util.regex.Pattern :cljs js/RegExp) ImplicitNav - (implicit-nav [this] (n/regex* this))) + (implicit-nav [this] (regex-nav this))) (defnav ^{:doc "Navigates to the provided val if the structure is nil. Otherwise it stays diff --git a/src/clj/com/rpl/specter/navs.cljc b/src/clj/com/rpl/specter/navs.cljc index 5bbde51..b9a9552 100644 --- a/src/clj/com/rpl/specter/navs.cljc +++ b/src/clj/com/rpl/specter/navs.cljc @@ -478,12 +478,6 @@ structure (updater structure next-fn)))) -(defnav regex* [re] - (select* [this structure next-fn] - (doseqres i/NONE [s (re-seq re structure)] - (next-fn s))) - (transform* [this structure next-fn] - (clojure.string/replace structure re next-fn))) (defn- update-first-list [l afn] (let [newf (afn (first l))