Skip to content

Instantly share code, notes, and snippets.

@Arrlindii
Created August 5, 2018 22:54
Show Gist options
  • Save Arrlindii/d459ea0d548503c181808bdfb37dfb01 to your computer and use it in GitHub Desktop.
Save Arrlindii/d459ea0d548503c181808bdfb37dfb01 to your computer and use it in GitHub Desktop.
func isEmailValid(_ value: String) -> Bool {
do {
if try NSRegularExpression(pattern: "^[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,4}$", options: .caseInsensitive).firstMatch(in: value, options: [], range: NSRange(location: 0, length: value.count)) == nil {
return false
}
} catch {
return false
}
return true
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment