1.3.0 permalink Arrow_down_16x16
  • (trim s)
Removes whitespace from both ends of string.

1 Example top

  • ;; 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 be converted to a string
    ;;    before being trimed.
    (use 'clojure.string)
    user=> (trim "     a      ")
    user=> (trim nil)  
    java.lang.NullPointerException (NO_SOURCE_FILE:0)
    user=> (trim 1.1)
    user=> (trim [1 2 3])
    "[1 2 3]"
Log in to add / edit an example.

See Also top

Log in to add a see also.

Plus_12x12 Minus_12x12 Source clojure/string.clj:184 top

(defn ^String trim
  "Removes whitespace from both ends of string."
  {:added "1.2"}
  [^CharSequence s]
  (.. s toString trim))
Vars in clojure.string/trim:
Used in 0 other vars

Comments top

No comments for trim. Log in to add a comment.