(filter #(re-find #"hello" (:a %))
[{:a "hi" :b 1} {:a "hello" :b 2} {:a "hellooo" :b 3}])
;;-> ({:a "hello" :b 2} {:a "hellooo" :b 3})
Filter maps whose key values contain a substring
-
13-10-2022 - |
Question
I have a set of maps I wish to filter. For instance, consider the set of maps
({:a "hi" :b 1} {:a "hello" :b 2} {:a "hellooo" :b 3})
I want to get
({:a "hello" :b 2} {:a "hellooo" :b 3})
As these two maps contain the substring "hello"
under the key :a
.
Solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow