trim

added
1.2

ns
clojure.string

type
function

(trim s)

Removes whitespace from both ends of string.

                ;; Trim basically does what you'd expect.  What the doc string
;; does not tell you however is that:
;;  - null will cause an error
;;  - non-string parameters will cause an error

(use 'clojure.string)
user=> (trim "     a      ")
"a"
user=> (trim nil)  
java.lang.NullPointerException (NO_SOURCE_FILE:0)
user=> (trim 1.1)
java.lang.Double cannot be cast to java.lang.CharSequence
user=> (trim [1 2 3])
clojure.lang.PersistentVector cannot be cast to java.lang.CharSequence