Re: Cocoa-dev Digest, Vol 5, Issue 1970
Re: Cocoa-dev Digest, Vol 5, Issue 1970
- Subject: Re: Cocoa-dev Digest, Vol 5, Issue 1970
- From: "Mr. Gecko" <email@hidden>
- Date: Tue, 18 Nov 2008 14:24:43 -0600
I've finally found it out. I decided to use NSXML instead of Regex and
it works perfectly.
NSXMLNode *recived = [[[NSXMLDocument alloc] initWithData:receivedData
options:NSXMLDocumentTidyHTML error:NULL] rootElement];
NSArray *recivedA = [recived nodesForXPath:@"//a" error:nil];
int i;
for (i=0; i<[recivedA count]; i++) {
NSXMLElement *link = [recivedA objectAtIndex:i];
NSLog(@"%@", [[link attributeForName:@"href"] stringValue]);
}
Thanks,
Mr. Gecko
On Nov 18, 2008, at 2:02 PM, email@hidden wrote:
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
_______________________________________________
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