拆分文字值
{-# LANGUAGE OverloadedStrings #-}
import qualified Data.Text as T
myText::T.Text
myText = "mississippi"
splitOn
在出現子字串時將 Text
分解為 Texts
列表。
ghci> T.splitOn "ss" myText
["mi","i","ippi"]
splitOn
是 intercalate
的反轉。
ghci> intercalate "ss" (splitOn "ss" "mississippi")
"mississippi"
split
將 Text
值分解為滿足布林謂詞的字元的塊。
ghci> T.split (== 'i') myText
["m","ss","ss","pp",""]