I am trying to validate a file name/ folder name when user try to change the name.
I know I should use Regex/ NSPredicate. However, I didn’t figure out after hours researching.
Appreciate if any experts can help me out.
Thanks a lot.
Was suggested by Madhumal Gunetileke:
I revised his code as below. It works for my case.
NSCharacterSet * set = [NSCharacterSet characterSetWithCharactersInString:@"\\/:*?\"<>|"];
if ([newName rangeOfCharacterFromSet:set].location != NSNotFound) {
NSLog(@"illegal Name");
return;
}
If you’re simply looking out to check whether the new name users provide are valid or not, you could try something like this;