Regex and ios5 stringByMatching ==> NSRegularExpression

How to change this line with equivalent NSRegularExpression

NSString* encodedPoints = [apiResponse stringByMatching:@"points:\\\"([^\\\"]*)\\\"" capture:1L]; 

thank

+4
regex ios5
Nov 17 '11 at 11:15
source share
1 answer

Remember that you need iOS 4.0 or higher to use this:

 NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:@"points:\\\"([^\\\"]*)\\\"" options:0 error:NULL]; NSTextCheckingResult *match = [regex firstMatchInString:apiResponse options:0 range:NSMakeRange(0, [apiResponse length])]; NSString *encodedPoints = [apiResponse substringWithRange:[match rangeAtIndex:1]]; 

Hope this helps.

+12
Mar 08 2018-12-12T00:
source share



All Articles