Skip to content

Instantly share code, notes, and snippets.

@michalmarczyk
Created May 21, 2010 07:45
Show Gist options
  • Save michalmarczyk/408594 to your computer and use it in GitHub Desktop.
Save michalmarczyk/408594 to your computer and use it in GitHub Desktop.
(let [#^java.util.regex.Pattern valid-chars
#"(?i)^[a-z0-9!$&*-_=+<>/.?%][a-z0-9!$&*-_=+<>/.?]*$"]
(defn clj-id? [#^String s]
(if (and (not (zero? (.length s)))
(.. valid-chars (matcher s) matches)
; (== (int -1) (.indexOf s ".."))
(let [slash (.indexOf s (int \/))]
(or (== (int -1) slash)
(== (int -1) (.indexOf s (int \/) (inc slash))))))
true
false)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment