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.

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

Environment

None

Attachments

2
  • 27 Aug 2015, 03:51 PM
  • 13 Jun 2015, 06:40 PM

Activity

andrewhr August 27, 2015 at 3:50 PM

Rebased patch against master.

David Nolen August 27, 2015 at 11:54 AM

This patch needs to be rebased to master.

andrewhr June 14, 2015 at 4:41 AM

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!

Completed

Details

Assignee

Reporter

Patch

Priority

Created June 9, 2015 at 8:06 PM
Updated August 27, 2015 at 5:14 PM
Resolved August 27, 2015 at 5:14 PM