regex - What is idiomatic clojure to validate that a string has only alphanumerics and hyphen? -


i need ensure input contains lowercase alphas , hyphens. what's best idiomatic clojure accomplish that?

in javascript this:

if (str.match(/^[a-z\-]+$/)) { ... } 

what's more idiomatic way in clojure, or if it, what's syntax regex matching?

user> (re-matches #"^[a-z\-]+$" "abc-def") "abc-def" user> (re-matches #"^[a-z\-]+$" "abc-def!!!!") nil user> (if (re-find #"^[a-z\-]+$" "abc-def")         :found) :found user> (re-find #"^[a-za-z]+" "abc.!@#@#@123") "abc" user> (re-seq #"^[a-za-z]+" "abc.!@#@#@123") ("abc") user> (re-find #"\w+" "0123!#@#@#abcd") "0123" user> (re-seq #"\w+" "0123!#@#@#abcd") ("0123" "abcd") 

Comments

Popular posts from this blog

matlab - "Contour not rendered for non-finite ZData" -

delphi - Indy UDP Read Contents of Adata -

javascript - Any ideas when Firefox is likely to implement lengthAdjust and textLength? -