剥离空白
{-# LANGUAGE OverloadedStrings #-}
import qualified Data.Text as T
myText::T.Text
myText = "\n\r\t leading and trailing whitespace \t\r\n"
strip
从 Text
值的开头和结尾删除空格。
ghci> T.strip myText
"leading and trailing whitespace"
stripStart
仅从一开始就删除空格。
ghci> T.stripStart myText
"leading and trailing whitespace \t\r\n"
stripEnd
只从末尾删除空格。
ghci> T.stripEnd myText
"\n\r\t leading and trailing whitespace"
filter
可用于从中间删除空格或其他字符。
ghci> T.filter /=' ' "spaces in the middle of a text string"
"spacesinthemiddleofatextstring"