I'm using the re-find function in clojure, and have something like this:
(defn some-function []
(re-find #"(?i)blah" "some sentence"))
What I would like is to make the "blah" dynamic, so I substituted a var for blah like this, but it doesn't work:
(defn some-function2 [some-string]
(re-find #(str "(?i)" some-string) "some sentence"))
I'm surprised this doesn't work since LISP is supposed to "treat code like data".
Use the function re-pattern. #"" is just a reader macro (aka. syntactic sugar for creating regex)
#(str "(?i)" some-string) is reader macro to create an anonymous functions.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With