Skip to content

Instantly share code, notes, and snippets.

View ekimber's full-sized avatar

Ed Kimber ekimber

View GitHub Profile
(defn camel-case-to-hyphenated
"Converts a camel case string to a hyphenated string.
E.g 'fooBar' -> 'foo-bar'"
[s]
(strs/join \- (drop-while empty?
(map #(if (re-matches #"[^a-z]{2,}" %) % (strs/lower-case %))
(strs/split s #"(?=[A-Z][a-z])|(?<=[a-z])(?=[A-Z])")))))
@ekimber
ekimber / camel
Last active August 29, 2015 14:09
camel case conversion
(join \- (map #(if (re-matches #"[^a-z]{2,}" %) % (lower-case %))(split "fooBarQUXXX" #"(?=[A-Z][a-z])|(?<=[a-z])(?=[A-Z])")))