有没有标准的方法在 Haskell 中拆分字符串?
lines并且words在空格或换行符上拆分效果很好,但肯定有一种标准的方式来拆分逗号吗?
lines
words
我在 Hoogle 上找不到。
具体来说,我正在寻找split "," "my,comma,separated,list"返回的东西["my","comma","separated","list"]。
split "," "my,comma,separated,list"
["my","comma","separated","list"]
有一个名为split的包。
cabal install split
像这样使用它:
ghci> import Data.List.Split ghci> splitOn "," "my,comma,separated,list" ["my","comma","separated","list"]
它带有许多其他功能,用于拆分匹配的分隔符或具有多个分隔符。