8000 * src/cljs/cljs/core.cljs: CLJS-116: re-pattern supports flags · clojure/clojurescript@65a9d4f · GitHub
[go: up one dir, main page]

Skip to content

Commit 65a9d4f

Browse files
committed
* src/cljs/cljs/core.cljs: CLJS-116: re-pattern supports flags
1 parent d9190cb commit 65a9d4f

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

src/cljs/cljs/core.cljs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2839,7 +2839,8 @@ reduces them without incurring seq initialization"
28392839
(defn re-pattern
28402840
"Returns an instance of RegExp which has compiled the provided string."
28412841
[s]
2842-
(js/RegExp. s))
2842+
(let [[_ flags pattern] (re-find #"^(?:\(\?([idmsux]*)\))?(.*)" s)]
2843+
(js/RegExp. pattern flags)))
28432844

28442845
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Printing ;;;;;;;;;;;;;;;;
28452846

test/cljs/cljs/core_test.cljs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -516,6 +516,7 @@
516516
(assert (= (re-matches (re-pattern "foo.*") "foo bar foo baz foo zot") "foo bar foo baz foo zot"))
517517
(assert (= (re-seq (re-pattern "foo") "foo bar foo baz foo zot") (list "foo" "foo" "foo")))
518518
(assert (= (re-seq (re-pattern "f(.)o") "foo bar foo baz foo zot") (list ["foo" "o"] ["foo" "o"] ["foo" "o"])))
519+
(assert (= (re-matches (re-pattern "(?i)foo") "Foo") "Foo"))
519520

520521
;; destructuring
521522
(assert (= [2 1] (let [[a b] [1 2]] [b a])))

0 commit comments

Comments
 (0)
0