I would like to remove the whitespace located after \n
.
For instance, username 123\n ugas 423\n peter 23\n asd234
would become username 123\nugas 423\npeter 23\nasd234
.
I am assuming you want to remove one or more whitespace characters at the beginning of each line, not just the first whitespace character. Also, I think you want to remove any kind of whitespace characters, like tabs, not just literal space characters.
import Data.Char
stripLeadingWhitespace :: String -> String
stripLeadingWhitespace = unlines . map (dropWhile isSpace) . lines
f [] = []
f ('\n':' ':a) = f ('\n' : a)
f (a:b) = a : f b
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With