fork download
  1. #import <objc/objc.h>
  2. #import <objc/Object.h>
  3. #import <Foundation/Foundation.h>
  4.  
  5. @implementation TestObj
  6.  
  7.  
  8.  
  9. NSUInteger checkPassword(NSString * haystack) {
  10. NSArray * arr = [NSArray arrayWithObjects: @"(?s).*\\d.*", @"(?s).*[a-z].*", @"(?s).*[A-Z].*", @"(?s).*[-+_!@#$%^&*.,?].*",nil];
  11. NSUInteger cnt = 0;
  12. for (NSUInteger index = 0; index < [arr count]; ++index) {
  13. NSPredicate * passTest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", [arr objectAtIndex:index]];
  14. if ([passTest evaluateWithObject:haystack]) {
  15. cnt = cnt + 1;
  16. }
  17. }
  18. if (cnt > 1 && [haystack length] > 5 && [haystack length] < 13)
  19. {
  20. NSLog(@"YES!");
  21. return 1;
  22. }
  23. else
  24. {
  25. NSLog(@"No!");
  26. return 0;
  27. }
  28. }
  29.  
  30. int main()
  31. {
  32. NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
  33. NSString * s = @"123DF4ffg";
  34. NSLog(@"Result: %d", checkPassword(s));
  35. return 0;
  36. }
  37. @end
Success #stdin #stdout #stderr 0.04s 42856KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
2016-03-21 08:50:19.755 prog[12444] YES!
2016-03-21 08:50:19.756 prog[12444] Result: 1