Skip to content

Instantly share code, notes, and snippets.

@chriswebb09
Created June 4, 2017 01:33
Show Gist options
  • Save chriswebb09/7eceaa9f6704eb6e3dd9f07170e113bc to your computer and use it in GitHub Desktop.
Save chriswebb09/7eceaa9f6704eb6e3dd9f07170e113bc to your computer and use it in GitHub Desktop.
extension String {
func isValidEmail() -> Bool {
let emailRegEx = "[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}"
let emailTest = NSPredicate(format:"SELF MATCHES %@", emailRegEx)
let result = emailTest.evaluate(with: self)
return result
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment