Clojure - Strings subs
Returns the substring of s beginning at start inclusive, and ending at end (defaults to length of string), exclusive.
Syntax
Following is the syntax.
(subs s start end)
Parameters − S is the input string. Start is the index position where to start the substring from. End is the index position where to end the substring.
Return Value − The substring.
Example
Following is an example of the string formatting in Clojure.
(ns clojure.examples.hello (:gen-class)) (defn hello-world [] (println (subs "HelloWorld" 2 5)) (println (subs "HelloWorld" 5 7))) (hello-world)
Output
The above program produces the following output.
llo Wo
clojure_strings.htm
Advertisements