import Text.Regex import Data.Maybe (fromJust) mail :: Regex mail = mkRegex "[a-zA-Z0-9]+@[a-zA-Z0-9]+" let mainmatch s = case m of { Nothing -> _; Just (pre, mm, post, _) -> mm:mainmatch post } where m = Text.Regex.matchRegexAll mail s