Reputation: 603
Is it possible to apply filter based on a regular expression? What I had in mind was something like
(filter #"<+\p{Alnum}+>" ["abc" "<def>"])
to return
=> ["<def>"]
Thanks in advance for hints.
Upvotes: 7
Views: 7202
Reputation: 14469
Put your regex inside an anonymous function that tests matching to your regex. The general form would be:
(filter #(re-matches REGEX %) SEQUENCE)
Where REGEX is the regex that you're interested in, and SEQUENCE is the sequence that you're interested in. Trying your example,
user> (filter #(re-matches #"<+\p{Alnum}+>" %) ["abc" "<def>"])
("<def>")
Upvotes: 9