Haskell Language Data.Text Splitting Text Values


{-# LANGUAGE OverloadedStrings #-}

import qualified Data.Text as T

myText :: T.Text
myText = "mississippi"

splitOn breaks a Text up into a list of Texts on occurrences of a substring.

ghci> T.splitOn "ss" myText

splitOn is the inverse of intercalate.

ghci> intercalate "ss" (splitOn "ss" "mississippi")

split breaks a Text value into chunks on characters that satisfy a Boolean predicate.

ghci> T.split (== 'i') myText