Behavior of clojure.string/replace differs from Clojure
Description
When using clojure.string/replace with a function as the replacement value, and using a regular expression with capturing groups, the behavior differs between Clojure and ClojureScript. In Clojure, the replacement fn is passed a tuple of the match and capturing group. In ClojureScript, it is only passed the match value.
Hi David, I understand and appreciate your concerns I just want to make clear what I've search and done, sorry if I sound rude - maybe I stepped on my language limitations.
Francis, really this re-* thing is tricky to deal with. I will take a closer look onto your ticket and see if I can add any idea.
Thanks everyone!
David Nolen June 14, 2015 at 2:51 AM
Andrew, was just looking for rationale. What you've done looks OK to me. People should try the patch and give feedback. Thanks!
When using clojure.string/replace with a function as the replacement value, and using a regular expression with capturing groups, the behavior differs between Clojure and ClojureScript. In Clojure, the replacement fn is passed a tuple of the match and capturing group. In ClojureScript, it is only passed the match value.
In Clojure:
=> (println (str/replace "foobar" #"f(o)o" #(do (println %) "X"))) [foo o] "Xbar"
In ClojureScript:
=> (println (str/replace "foobar" #"f(o)o" #(do (println %) "X"))) foo Xbar