In this guide, we will discuss Clojure Strings Split. Splits string on a regular expression.
Syntax
Following is the syntax.
(split str reg)
Parameters − ‘str’ is the string which needs to be split. ‘reg’ is the regular expression based on which the string split needs to happen.
Return Value − The split string.
Example
Following is an example of split in Clojure.
(ns clojure.examples.hello (:gen-class)) (defn hello-world [] (println (clojure.string/split "Hello World" #" "))) (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
Pingback: Clojure - Strings join | Adglob Infosystem Pvt Ltd
Pingback: Clojure - Strings | Adglob Infosystem Pvt Ltd