Clojure - Strings trim



Removes whitespace from both ends of the string.

Syntax

Following is the syntax.

(trim str)

Parameters − ‘str’ is the input string.

Return Value − The string which has the whitespaces removed.

Example

Following is an example of trim in Clojure.

(ns clojure.examples.hello
   (:gen-class))
(defn hello-world []
   (println (clojure.string/trim " White spaces ")))
(hello-world)

Output

The above program produces the following output.

White spaces
clojure_strings.htm
Advertisements