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

前端 未结 12 1400
感情败类
感情败类 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 09:11

    Another (std) solution

    import System.Environment
    import Data.Text
    
    strip :: String -> IO String
    strip = return . unpack . Data.Text.strip . pack
    
    main = getLine >>= Main.strip >>= putStrLn
    

提交回复
热议问题