Bem util ! Seguem exemplos pra quem não vive sem:
- (BOOL)assertRegex:(NSString*)stringToSearch withRegex:(NSString*)regexString {
NSPredicate *regex = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", regexString];
return [regex evaluateWithObject:stringToSearch];
}
- (void)testRegexes {
// Find a string at the end of a line.
STAssertTrue([self assertRegex:@"Christopher Bartling"
withRegex:@".*Bartling$"], @"Regex did not match.");
// Find a string at the beginning of a line.
STAssertTrue([self assertRegex:@"Christopher Bartling"
withRegex:@"^Chris.*"], @"Regex did not match.");
// Find a sequence of 3 characters in succession using an interval quantifier (e.g {3,3}).
STAssertTrue([self assertRegex:@"**** = *** === ****** == *****"
withRegex:@".*={3,3}.*"], @"Regex did not match.");
}
A quem mais interessar também existem algumas frameworks para isso:
http://regexkit.sourceforge.net/
http://sourceforge.net/projects/objpcre
Promoções na App Store: Star Wars: KOTOR II, Old Monterrey: Pixel
Adventure, Cash Log Basic e mais!
-
Abrindo a semana e o mês de maio nesta segunda-feira, com a nossa seleção
de promoções na App…
Há 5 dias


