In Haskell, how do you trim whitespace from the beginning and end of a string?

前端 未结 12 1462
感情败类
感情败类 2021-01-01 08:45

How do you trim whitespace from the start and end of a string?

trim \"  abc \" 

=>

\"abc\"

Edit:

Ok, let me be a little cleare

12条回答
  •  误落风尘
    2021-01-01 08:51

    Inefficient but easy to understand and paste in where needed:

    strip = lstrip . rstrip
    lstrip = dropWhile (`elem` " \t")
    rstrip = reverse . lstrip . reverse
    

提交回复
热议问题