R X
R X

Reputation: 281

Multiple regex patterns in Clojure?

I'm trying to make my code more readable but still try have as much sense as possible, I would like to test a string vs a few regex patterns.

( re-find #"(?i)(^select .* from .*)|(^delete from me)" c))

And I would like to split this into 2 separate patterns but maybe use one test? is there anything that would test a set of patterns vs 1 string?

Thanks!

Upvotes: 3

Views: 910

Answers (1)

Kyle
Kyle

Reputation: 22258

(def patterns [#"(?i)^select .* from .*" #"(?i)^delete from me"])

(when (some #(re-find % "your test string") patterns)
 ...)

clojure.core/some

Upvotes: 4

Related Questions