拆分字符串基于轉(zhuǎn)義字符\ n或\ r \ n。
以下是split-lines的基本使用語法:
(split-lines str)
參數(shù)? 'str'是需要拆分的字符串。
返回值 ? 拆分后的字符串。
下面是split-lines函數(shù)的示例:
(ns clojure.examples.hello (:gen-class)) (defn hello-world [] (println (clojure.string/split-lines "Hello\nWorld"))) (hello-world)
以上示例將輸出以下結(jié)果:
[Hello World]
注意在上面的輸出中,字符串“Hello”和“World”是單獨的字符串。
更多建議: