(replace s match replacement)
Replaces all instance of match with replacement in s.
match/replacement can be:
string / string
pattern / (string or function of match).
Source
(defn
replace
"Replaces all instance of match with replacement in s.\n match/replacement can be:\n\n string / string\n pattern / (string or function of match)."
[s match replacement]
(cond
(string? match)
(.replace
s
(js/RegExp. (gstring/regExpEscape match) "g")
replacement)
(instance? js/RegExp match)
(if
(string? replacement)
(replace-all s match replacement)
(replace-all s match (replace-with replacement)))
:else
(throw (str "Invalid match arg: " match))))