
On 3/30/07, Stefan O'Rear
On Fri, Mar 30, 2007 at 05:43:34AM +0200, paolino wrote:
Hi, I had a bad time trying to parse the words of a text. I suspect I miss some parsec knowledge.
I'd start by not sextuple-posting, it just sextuples the ugliness ;-) Mhh, still I don't see any them in my inbox mails , probably something buggy in gmail configuration, sorry :/.
import Char( isAlpha ) import List( groupBy )
equating f x y = f x == f y -- in Data.Eq, iff you have GHC 6.7
isLetter x = isAlpha x || x == '_' || x == '@'
myWords = filter (isLetter . head) . groupBy (equating isLetter)
Testing your code, it misses the words with numbers inside exclusion and uses the number as separators. !runhaskell prova.hs ["paolo@gmail","sara","mimmo","ab","a","b","ab","cd"] Thanks