Is there a standard way to split a string in Haskell?
lines
and words
work great from splitting on a space or newline, but surely there is
Without importing anything a straight substitution of one character for a space, the target separator for words
is a space. Something like:
words [if c == ',' then ' ' else c|c <- "my,comma,separated,list"]
or
words let f ',' = ' '; f c = c in map f "my,comma,separated,list"
You can make this into a function with parameters. You can eliminate the parameter character-to-match my matching many, like in:
[if elem c ";,.:-+@!$#?" then ' ' else c|c <-"my,comma;separated!list"]