tags:

views:

16

answers:

1

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: 

[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].

KennyTM
thanks kenny. kenny is there any solution or api to know about invalid RE before calling NSPredicate
pawan.mangal
@pawan: You could use [exception handling](http://developer.apple.com/library/ios/#documentation/cocoa/Conceptual/ObjectiveC/Articles/ocExceptionHandling.html).
KennyTM