Revision: 55638
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at February 15, 2012 04:34 by BenClayton
Initial Code
NSRegularExpression* exp = [NSRegularExpression regularExpressionWithPattern:@"(put)-(expression)-(here)" options:NSRegularExpressionSearch error:&error]; if (error) { NSLog(@"%@", error); } else { NSTextCheckingResult* result = [exp firstMatchInString:testString options:0 range:NSMakeRange(0, [productDescription length] ) ]; if (result) { NSRange groupOne = [result rangeAtIndex:1]; // 0 is the WHOLE string. NSRange groupTwo = [result rangeAtIndex:2]; NSRange groupThree = [result rangeAtIndex:3]; NSLog( [testString substringWithRange:groupOne] ); NSLog( [testString substringWithRange:groupTwo] ); NSLog( [testString substringWithRange:groupThree] ); } }
Initial URL
Initial Description
Extract groups from a Regular Expression
Initial Title
iOS / iPhone: Extract groups from a Regular Expression (NSRegularExpression)
Initial Tags
iphone, ios
Initial Language
Objective C