LoginSignup
23

More than 5 years have passed since last update.

UITextFieldでemailのvalidate

Posted at

その文字列がメールアドレスか調べる関数

    /// その文字列がメールアドレスかどうか調べる
    class func isValidEmail(string: String) -> Bool {
        println("validate calendar: \(string)")
        let emailRegEx = "[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,4}"
        var emailTest = NSPredicate(format:"SELF MATCHES %@", emailRegEx)
        let result = emailTest?.evaluateWithObject(string)
        return result!
    }

٩(๑❛ᴗ❛๑)۶

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
23