문제

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.

도움이 되었습니까?

해결책

(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}) 
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top