返回從包含開始到結(jié)束(默認(rèn)為字符串的長度)的“s”的子字符串“exclusive”。
以下是subs的基本使用語法:
(subs s start end)
參數(shù) ? 'S'是輸入字符串。 'Start'是從中開始子串的索引位置。 'End'是索引位置,用于結(jié)束子字符串。
返回值 ? 子字符串。
下面是subs函數(shù)的示例:
(ns clojure.examples.hello (:gen-class)) (defn hello-world [] (println (subs "HelloWorld" 2 5)) (println (subs "HelloWorld" 5 7))) (hello-world)
以上示例將輸出以下結(jié)果:
llo Wo
更多建議: