(clojure.string/split "hello world" #" ")
["你好"世界"]
而
(clojure.string/split "hello|world" #"|")
输出: ["h" "e" "l" "l" "o" "|" "w" "o" "r" "l" "d"]
为什么字符串没有在"|"上拆分?
|
在正则表达式中具有特殊含义,因此如果要拆分该文字字符,则必须对其进行转义(通过以为前缀(:
(clojure.string/split "hello|world" #"|")
=> ["hello" "world"]