Clojure - Strings split-lines


Advertisements

Split strings is based on the escape characters \n or \r\n.

Syntax

Following is the syntax.

(split-lines str)

Parameters − ‘str’ is the string which needs to be split.

Return Value − The split string.

Example

Following is an example of split-lines in Clojure.

(ns clojure.examples.hello
   (:gen-class))
(defn hello-world []
   (println (clojure.string/split-lines "Hello\nWorld")))
(hello-world)

Output

The above program produces the following output.

[Hello World]

Note that in the above output, both the strings “Hello” and “World” are separate strings.

clojure_strings.htm
Advertisements