正则表达式和ios5 stringByMatching ==> NSRegularExpression [英] regex and ios5 stringByMatching ==> NSRegularExpression
本文介绍了正则表达式和ios5 stringByMatching ==> NSRegularExpression的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何使用等效的NSRegularExpression更改此行
How do I change this line with the equivalent NSRegularExpression
NSString* encodedPoints = [apiResponse stringByMatching:@"points:\\\"([^\\\"]*)\\\"" capture:1L];
谢谢
推荐答案
请记住,您需要iOS 4.0或更高版本才能使用此功能:
Remember that you need iOS 4.0 or greater 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]];
希望有所帮助。
这篇关于正则表达式和ios5 stringByMatching ==> NSRegularExpression的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文