简体   繁体   中英

Filter letters from string replacing symbols for blanks spaces and letters lowercase

Example: "Paul's! Come There"

GetOutput: "paul s come there"

 myFilter :: String -> String
 myFilter str = unwords . filter (not . null) . map (
                              map toLower . filter  isLetter
                              ) . words $ str

How can I filter the letters into lowerCase and at the same time replace all non-word symbols with blanks?

@Cirdec That's the idea. To get the syntax correct that would be map (\\c -> if not (isLetter c) then ' ' else c) (note the parenthesis) which is the same as map (\\c -> if isLetter c then c else ' ')

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM