奇怪的事情与克洛朱尔分裂

  • 本文关键字:朱尔 分裂 regex
  • 更新时间 :
  • 英文 :

(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"]

最新更新