You're viewing version 1.2.0 of trimr. The latest stable version of Clojure Core is 1.3.0.
1.2.0 Arrow_down_16x16
  • (trimr s)
Removes whitespace from the right side of string.

1 Example top

  • (use 'clojure.string)
    (trimr "        my string         ")
    => "        my string"
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:201 top

(defn ^String trimr
  "Removes whitespace from the right side of string."
  {:added "1.2"}
  [^CharSequence s]
  (loop [index (.length s)]
    (if (zero? index)
      ""
      (if (Character/isWhitespace (.charAt s (dec index)))
        (recur (dec index))
        (.. s (subSequence 0 index) toString)))))
Vars in clojure.string/trimr: .. dec defn loop zero?
Used in 0 other vars

Comments top

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