剝離空白
{-# 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"