Re: Regex
Re: Regex
NSPredicate can handle ICU standard regex matches.
More info in the NSPredicate docs.
The following snippet validates a UUID.
/*
is UUID
see http://www.stiefels.net/2007/01/24/regular-expressions-for-nsstring/
*/
- (BOOL)isUUID
{
NSString *regex = @"^(([0-9a-fA-F]){8}-([0-9a-fA-F]){4}-([0-9a-fA-F])
{4}-([0-9a-fA-F]){4}-([0-9a-fA-F]){12})$";
// supported non standard regex format is at http://www.icu-project.org/userguide/regexp.html
NSPredicate *regextest = [NSPredicate predicateWithFormat:@"SELF
MATCHES %@", regex];
return [regextest evaluateWithObject:self];
}
Jonathan Mitchell
Central Conscious Unit
http://www.mugginsoft.com
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden