Here, use your string from UITextFieldor from any other source to find it in any uppercaseor not.
NSString *str = @"Apple";
NSCharacterSet *cset = [NSCharacterSet uppercaseLetterCharacterSet];
NSRange range = [str rangeOfCharacterFromSet:cset];
if (range.location == NSNotFound) {
NSLog(@"not any capital");
} else {
NSLog(@"has one capital");
}
: 1. 6 . 2. , . Nirmal Choudhari regex
- (BOOL)containsValidPassword:(NSString*)strText
{
NSString* const pattern = @"^.*(?=.{6,})(?=.*[a-z])(?=.*[A-Z]).*$";
NSRegularExpression* regex = [[NSRegularExpression alloc] initWithPattern:pattern options:0 error:nil];
NSRange range = NSMakeRange(0, [strText length]);
return [regex numberOfMatchesInString:strText options:0 range:range] > 0;
}
:
NSString *str = @"appLe";
BOOL isValid = [self containsValidPassword:str];
if (isValid) {
NSLog(@"valid");
} else {
NSLog(@"not valid");
}