Sha256: 34743a30f60cff5d6ced7b03ae206450f7bdb568b38e65db6310e84ee519cb18
Contents?: true
Size: 571 Bytes
Versions: 396
Compression:
Stored size: 571 Bytes
Contents
(ns phone-number (:require [clojure.string :as str])) (defn- digits-only [input] (str/replace input #"\D" "")) (defn- extract-parts [input] (if-let [matches (re-find #"^1?(...)(...)(....)$" input)] (rest matches) ["000" "000" "0000"])) (defn- parts [input] (-> input digits-only extract-parts)) (defn number [input] (str/join (parts input))) (defn area-code [input] (first (parts input))) (defn pretty-print [input] (let [[area-code exchange subscriber] (parts input)] (str "(" area-code ") " exchange "-" subscriber)))
Version data entries
396 entries across 396 versions & 1 rubygems