function | since v0.0-927 | clojure.core/re-pattern | Edit |
(re-pattern s)
Returns an instance of RegExp which has compiled the provided string.
Returns an instance of RegExp which has compiled the provided string.
(defn re-pattern
[s]
(if (instance? js/RegExp s)
s
(let [[prefix flags] (re-find #"^\(\?([idmsux]*)\)" s)
pattern (subs s (if (nil? prefix)
0
(count ^string prefix)))]
(js/RegExp. pattern (or flags "")))))