You can create your own character set:
NSCharacterSet *s = [NSCharacterSet characterSetWithCharactersInString:@"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890_"];
After that, you flip it to anything that is not in the original line:
s = [s invertedSet];
And then you can use the string method to find out if your string contains anything in the inverted set:
NSRange r = [string rangeOfCharacterFromSet:s]; if (r.location != NSNotFound) { NSLog(@"the string contains illegal characters"); }
Dave DeLong Sep 25 2018-11-15T00: 00Z
source share