iOS 正则表达式入门

正则表达式入门

正则表达式工具表

例:

// 请输入首位为字母,6-20位数字或字母组合的账号
+ (BOOL)isVaildAccount:(NSString *)account {
    
    NSString *format = @"^([A-Za-z])[A-Za-z0-9]{5,19}$";
    NSPredicate *predicate = [NSPredicate predicateWithFormat:@"Self matches %@", format];
    BOOL isVaildAccount = [predicate evaluateWithObject:account];
    return isVaildAccount;
}

你可能感兴趣的:(iOS 正则表达式入门)