Skip to content

Instantly share code, notes, and snippets.

@alexanderkhitev
Last active December 4, 2017 09:23
Show Gist options
  • Save alexanderkhitev/93bee949907d4c482bb8d413800daeda to your computer and use it in GitHub Desktop.
Save alexanderkhitev/93bee949907d4c482bb8d413800daeda to your computer and use it in GitHub Desktop.
isValidEmail string extension for swift 3
var isValidEmail: Bool {
do {
let regex = try NSRegularExpression(pattern: "[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,6}", options: .caseInsensitive)
return (regex.firstMatch(in: self, options: [], range: NSMakeRange(0, self.characters.count)) != nil)
} catch {
debugPrint(error.localizedDescription)
return false
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment