Sono abbastanza verde all'espressione regolare con Objective-C. Sto avendo qualche difficoltà con questo.Objective-C NSRegularExpressions, trovando la prima occorrenza di numeri in una stringa
NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:@"\\b([1-9]+)\\b" options:NSRegularExpressionCaseInsensitive error:®Error];
if (regError) {
NSLog(@"%@",regError.localizedDescription);
}
__block NSString *foundModel = nil;
[regex enumerateMatchesInString:self.model options:kNilOptions range:NSMakeRange(0, [self.model length]) usingBlock:^(NSTextCheckingResult *match, NSMatchingFlags flags, BOOL *stop) {
foundModel = [self.model substringWithRange:[match rangeAtIndex:0]];
*stop = YES;
}];
Tutto quello che sto cercando di fare è prendere una stringa come
150A
E ottenere
150
Così perfetto. Grazie! – rnystrom