Skip to content

Instantly share code, notes, and snippets.

@sjehutch
Created January 2, 2018 10:16
Show Gist options
  • Save sjehutch/4261dc83087ddbf61c3ed7554fe6e1fa to your computer and use it in GitHub Desktop.
Save sjehutch/4261dc83087ddbf61c3ed7554fe6e1fa to your computer and use it in GitHub Desktop.
validate email method swift
func isValidEmail(testStr:String) -> Bool {
let emailRegEx = "[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,64}"
let emailTest = NSPredicate(format:"SELF MATCHES %@", emailRegEx)
return emailTest.evaluate(with: testStr)
}
isValidEmail(testStr: "sjehutchmail.com")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment