Clojure - 字串 split-lines



字串分割基於跳脫字元 \n 或 \r\n。

語法

以下是語法。

(split-lines str)

引數 - ‘str’ 是需要分割的字串。

返回值 - 分割後的字串。

示例

以下是 Clojure 中 split-lines 的示例。

(ns clojure.examples.hello
   (:gen-class))
(defn hello-world []
   (println (clojure.string/split-lines "Hello\nWorld")))
(hello-world)

輸出

以上程式產生以下輸出。

[Hello World]

請注意,在以上輸出中,“Hello”和“World”都是獨立的字串。

clojure_strings.htm
廣告

© . All rights reserved.