Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
是否有一些正则表达式可以传递给 re-seq 使其表现得像.split?
.split
user=> (seq (.split "a,b,c,,e" ",")) ("a" "b" "c" "" "e") user=> (re-seq #"[^,]" "a,b,c,,e") ("a" "b" "c" "e") user=>
如您所见,正则表达式[^,]不太可接受,因为它不会在分隔文件中的空列上拾取。我是坚持.split还是可以re-seq工作?
[^,]
re-seq
尝试
(re-seq #"[^,]+|(?<=,)(?=,)" "a,b,c,,e")
我希望 Clojure 正则表达式支持后向断言。
解释:
[^,]+ # Either match one or more non-comma characters | # or (?<=,)(?=,) # match the empty string between two commas