I would like to remove the space after \n .
\n
For example, username 123\n ugas 423\n peter 23\n asd234 becomes username 123\nugas 423\npeter 23\nasd234 .
username 123\n ugas 423\n peter 23\n asd234
username 123\nugas 423\npeter 23\nasd234
f [] = [] f ('\n':' ':a) = f ('\n' : a) f (a:b) = a : fb
I assume that you want to remove one or more whitespace characters at the beginning of each line, not just the first space character. Also, I think you want to remove any whitespace characters, such as tabs, not just alphabetic spaces.
import Data.Char stripLeadingWhitespace :: String -> String stripLeadingWhitespace = unlines . map (dropWhile isSpace) . lines