In Clojure, you usually do this with a regex. In Java regular expressions, you can do this by specifying a checkbox for case insensitivity for the match you want to do, or at the beginning of a regular expression for global case insensitivity:
(filter #(re-find #"(?i)a" %) ["Lion" "Zebra" "Buffalo" "Antelope"])
Pure Javascript regular expressions only support global flags. They are passed as a string as a second parameter to the regex constructor:
(filter #(re-find (js/RegExp. "a" "i") %) ["Lion" "Zebra" "Buffalo" "Antelope"])
However, since the convenience and preservation of regular expressions between Java and Javascript is similar, the Clojurescript reader translates Java-style global flags (those at the beginning of the regular expression) into their global Javascript equivalent.
So, the first example also works in Clojurescript. Keep in mind that non-global flags will not work in Clojurescript, where they will work in Clojure.
Nielsk
source share