[Haskell-cafe] striping non-alphanumericals
ok at cs.otago.ac.nz
ok at cs.otago.ac.nz
Wed Dec 11 23:48:31 UTC 2013
> What I want to to there is to get i.e. "word," or "word!" etc. and arrive
> at
> "word". I understand that escapeRe may do this.
Why not do it the easy way?
import Char(isAlpha)
keep_letters = filter isAlphs
Then keep_letters "word," = keep_letters "(w)ord" = "word".
If you are content to work with Unicode, you get use
getLine :: IO ByteString and
splitWith :: (Word8 -> Bool) -> ByteString -> [ByteString]
with predicate not . isAlpha . chr . fromIntegral
and then filter out the empty ByteStrings
More information about the Haskell-Cafe
mailing list