Created
June 10, 2015 06:50
-
-
Save qdequele/51aac6419a957eef0bf2 to your computer and use it in GitHub Desktop.
How to know if string is a email with a swift regex
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func isValidEmail(testStr:String) -> Bool { | |
let emailRegEx = "[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,4}" | |
let emailTest = NSPredicate(format:"SELF MATCHES %@", emailRegEx) | |
return emailTest.evaluateWithObject(testStr) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment