Details
-
Type:
Defect
-
Status:
Closed
-
Priority:
Minor
-
Resolution: Completed
-
Affects Version/s: Release 1.3
-
Fix Version/s: None
-
Component/s: None
-
Labels:None
-
Patch:Code and Test
Description
clojure.string/replace only gives special treatment to replacement string when match is a regex pattern. clojure.string/replace-first does so in those cases, but also when match is a string to be matched literally. For example, these cases are not consistent with each other:
user=> (require '[clojure.string :as str])
nil
user=> (str/replace "food" "o" "$")
"f$$d"
user=> (str/replace-first "food" "o" "$")
java.lang.StringIndexOutOfBoundsException: String index out of range: 1 (NO_SOURCE_FILE:0)
Suggested fix for
CLJ-905, plus addition of function clojure.string/re-qr for quoting replacement strings that caller wishes to be treated literally when match is a pattern.CLJ-905, plus addition of function clojure.string/re-qr for quoting replacement strings that caller wishes to be treated literally when match is a pattern.