Search This Blog

Thứ Năm, 31 tháng 8, 2017

Kiểm tra có phải là email in IOS

  static func isValidEmail(testStr:String) -> Bool {
        // print("validate calendar: \(testStr)")
        let emailRegEx = "[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}"
        
        let emailTest = NSPredicate(format:"SELF MATCHES %@", emailRegEx)
        return emailTest.evaluate(with: testStr)

    }

Không có nhận xét nào:

Đăng nhận xét