Skip to content

Instantly share code, notes, and snippets.

@duairc
Created May 5, 2010 18:31
Show Gist options
  • Save duairc/391235 to your computer and use it in GitHub Desktop.
Save duairc/391235 to your computer and use it in GitHub Desktop.
import Data.Char
atLeastOneFollowedByAndThen f c g [] = False
atLeastOneFollowedByAndThen f c g (x:xs) = f x && yys /= [] && y == c && g ys
where yys = dropWhile f xs
~(y:ys) = yys
isEmail = atLeastOneFollowedByAndThen isAlphaNum '@' isDomain
isDomain = atLeastOneFollowedByAndThen isAlphaNum '.' (\t -> isTerminator t || isDomain t)
isTerminator = (`elem` ["com", "net", "org", "ie"])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment