Clojure – Strings split-lines

Clojure strings split-lines

In this guide, we will discuss Clojure Strings split-lines. 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.

Next Topic : Click Here

This Post Has 2 Comments

Leave a Reply