Skip to content

Instantly share code, notes, and snippets.

@zkessin
Created July 18, 2016 04:32
Show Gist options
  • Save zkessin/e19640130ba33099a9c209b98b012815 to your computer and use it in GitHub Desktop.
Save zkessin/e19640130ba33099a9c209b98b012815 to your computer and use it in GitHub Desktop.
Module MatchEmail exposing (..)
import Regex exposing (..)
bodyHasEmail : String -> Maybe String
bodyHasEmail bodyText =
let -- "\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}\b"
re = regex "\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}\b"
|> caseInsensitive
limit =(AtMost 1)
match = find limit re bodyText
in
case head match of
Nothing -> Nothing
Just email -> Just email.match
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment