File tree Expand file tree Collapse file tree 2 files changed +9
-2
lines changed Expand file tree Collapse file tree 2 files changed +9
-2
lines changed Original file line number Diff line number Diff line change 26
26
27
27
(defn- replace-all
28
28
[s re replacement]
29
- (.replace s (js/RegExp. (.-source re) " g" ) replacement))
29
+ (let [r (js/RegExp. (.-source re)
30
+ (cond-> " g"
31
+ (.-ignoreCase re) (str " i" )
32
+ (.-multiline re) (str " m" )
33
+ (.-unicode re) (str " u" )))]
34
+ (.replace s r replacement)))
30
35
31
36
(defn- replace-with
32
37
[f]
Original file line number Diff line number Diff line change 25
25
(is (= " FOObarFOO" (s/replace " foobarfoo" #"foo" s/upper-case)))
26
26
(is (= " barbar)foo" (s/replace " foo(bar)foo" " foo(" " bar" )))
27
27
(is (= " FOO-ObarFOO-O"
28
- (s/replace " foobarfoo" #"f(o)o" (fn [[m g1]] (s/upper-case (str m " -" g1)))))))
28
+ (s/replace " foobarfoo" #"f(o)o" (fn [[m g1]] (s/upper-case (str m " -" g1))))))
29
+ (is (= " faabarfaa" (s/replace " FOObarfoo" #"(?i)foo" " faa" )))
30
+ (is (= " aaa\n ccc" (s/replace " aaa\n bbb" #"(?m)^bbb" " ccc" ))))
29
31
30
32
(testing " Testing string join"
31
33
(is (= " " (s/join nil )))
You can’t perform that action at this time.
0 commit comments