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