Skip to content

Instantly share code, notes, and snippets.

@sktoiva
Last active December 6, 2015 19:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sktoiva/0e70ffe6b077d323b73f to your computer and use it in GitHub Desktop.
Save sktoiva/0e70ffe6b077d323b73f to your computer and use it in GitHub Desktop.
Trim all whitespace
(ns trim-all.core
(:require [clojure.string :as str]))
(defn trim-all [s]
(->> s
(re-seq #"\".*?\"|\S+")
(str/join " ")))
(comment
(trim-all " Foo Baoeuaeuar \" Foo Bar\" aonethu aent saetnh aseonthu \"Fo aoeshd \"")
;;=>"Foo Baoeuaeuar \" Foo Bar\" aonethu aent saetnh aseonthu \"Fo aoeshd \""
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment