1、判斷郵箱格式(swift)
let regex = "[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,6}"
let testEmail = NSPredicate(format:"SELF MATCHES %@", regex)
let status = testEmail.evaluateWithObject(emailText)//BOOL
2缎谷、判斷是否是手機(jī)號(hào)(OC)
- (BOOL)isPhoneNum{
NSString *MOBILE = @"^1(3[0-9]|4[57]|5[0-35-9]|8[0-9]|7[0678])\\d{8}$";
NSPredicate *regextestmobile = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", MOBILE];
return [regextestmobile evaluateWithObject:self.numberTF.text];
}