Multiple regex patterns in Clojure?

I am trying to make my code more readable, but still try to make as much sense as possible, I would like to validate a string against multiple 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 to check the template set vs 1 string?

Thank!

+3


source to share


1 answer


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

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

      



clojure.core / some

+4


source







All Articles