When we are using localization and regular expression in our iphone application. And when we are not using the english language.
Then how to convert that regular expression in relative language.
If i am using below regular expression:
+ (BOOL) isAlphabetsOnly:(NSString *) candidate {
if (![self isEmpty:candidate]) {
NSString *alphaRegex = @"^\\s*([A-Za-z ]*)\\s*$";
NSPredicate *alphaTest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", alphaRegex];
return [alphaTest evaluateWithObject:candidate];
}
return NO;
}
It’s work fine for the english. But not for other language. Then how can we convert it into other language. So it will work in different language to.
Please help me.
Thanks,
I have never worked on the iOS but according to here if you use something like so:
^\\s*([\\s]*)\\s*$should work across different locales.Edit: Yes you are correct, my bad. As stated in here you should be able to do what you need using the
\p{L}you should be able to match any letter:^\\s*([\\p{L}\\s]*)\\s*$