悟空记账

NSString+JZExtension.m 647B

12345678910111213141516171819202122232425
  1. //
  2. // NSString+JZExtension.m
  3. // JIZHANG
  4. //
  5. // Created by jikaipeng on 2017/10/26.
  6. // Copyright © 2017年 kuxuan. All rights reserved.
  7. //
  8. #import "NSString+JZExtension.h"
  9. @implementation NSString (JZExtension)
  10. +(BOOL)judgePassWordLegal:(NSString *)pass{
  11. BOOL result = false;
  12. if ([pass length] >= 6){
  13. // 判断长度大于6位后再接着判断是否同时包含数字和字符
  14. NSString * regex = @"^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{6,16}$";
  15. NSPredicate *pred = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", regex];
  16. result = [pred evaluateWithObject:pass];
  17. }
  18. return result;
  19. }
  20. @end