clojure.string/trim-newline

functionsince v0.0-927 clojure.string/trim-newlineEdit
(trim-newline s)

Details:

Removes all trailing newline \n or return \r characters from string.

Similar to Perl's chomp.


Source docstring:
Removes all trailing newline \n or return \r characters from
string.  Similar to Perl's chomp.
Source code @ clojurescript:src/main/cljs/clojure/string.cljs
(defn ^string trim-newline
  [s]
  (loop [index (.-length s)]
    (if (zero? index)
      ""
      (let [ch (get s (dec index))]
        (if (or (identical? \newline ch)
                (identical? \return ch))
          (recur (dec index))
          (.substring s 0 index))))))