how handle error in NSPredicate

匿名 (未验证) 提交于 2019-12-03 02:42:02

问题:

when i try to match regular expression for Data . sometime application crashes with error

here is error description

'Can't do regex matching, reason: Can't open pattern U_REGEX_INVALID_RANGE (string Ertyu, pattern [a-Z], case 0, canon 0)'

here is my code

 - (BOOL)isValidateString:(NSString *)inString ForRE:(NSString *)inRE { BOOL isValidate=NO; NSPredicate *thePredicate= [NSPredicate predicateWithFormat:@"SELF MATCHES %@", inRE];  isValidate= [thePredicate evaluateWithObject:inString]; return isValidate; 

}

and in this method RE is getting from server.

回答1:

[a-Z] is an invalid range because Z is before a in Unicode. If you want to match all alphabets, make the server return [a-zA-Z].



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!