如何从字符串中删除单词列表

Zel*_*jko 6 string clojure stop-words

我想做什么(在Clojure中):

例如,我有一个需要删除的单词向量:

(def forbidden-words [":)" "the" "." "," " " ...many more...])
Run Code Online (Sandbox Code Playgroud)

......和一个字符串向量:

(def strings ["the movie list" "this.is.a.string" "haha :)" ...many more...])
Run Code Online (Sandbox Code Playgroud)

因此,应从每个字符串中删除每个禁用的单词,在这种情况下,结果将是:["movie list""thisisastring""haha"].

这该怎么做 ?

cgr*_*and 7

(def forbidden-words [":)" "the" "." ","])
(def strings ["the movie list" "this.is.a.string" "haha :)"])
(let [pattern (->> forbidden-words (map #(java.util.regex.Pattern/quote %)) 
                (interpose \|)  (apply str))]
  (map #(.replaceAll % pattern "") strings))
Run Code Online (Sandbox Code Playgroud)