Monday, April 30, 2012

How to find if NSString contains decimal + certain other characters.

NSMutableCharacterSet *_mySet = [NSMutableCharacterSet characterSetWithCharactersInString:@"aAfF"];
[_mySet formUnionWithCharacterSet:[NSCharacterSet decimalDigitCharacterSet]];
NSCharacterSet *myStringSet = [NSCharacterSet characterSetWithCharactersInString:mystring];

if ([_mySet isSupersetOfSet: myStringSet])
//This is will be true if myString contains ONLY " decimal numbers(0-9) and characters a,A,f,F"

Note: First 2 code lines tell you how to join 2 character sets.

No comments:

Post a Comment