1、判斷使用者名稱,在2-16位
-(BOOL)CheckInput:(NSString *)_text
{
NSString *Regex = @"^\\w{2,16}$";
NSPredicate *emailTest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", Regex];
return [emailTest evaluateWithObject:_text];
}
2、判斷手機號碼,1開頭的十一位元字
-(BOOL)CheckInput:(NSString *)_text
{
NSString *Regex = @"1\\d{10}";
NSPredicate *emailTest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", Regex];
return [emailTest evaluateWithObject:_text];
}
3、判斷郵箱
-(BOOL)CheckInput:(NSString *)_text
{
NSString *Regex = @"[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,4}";
NSPredicate *emailTest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", Regex];
return [emailTest evaluateWithObject:_text];
}
4、判斷密碼,6-16位
-(BOOL)CheckInput:(NSString *)_text
{
NSString *Regex = @"\\w{6,16}";
NSPredicate *emailTest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", Regex];
return [emailTest evaluateWithObject:_text];
}