给定一个NSString *test = @"...href="/functions?q=KEYWORD\x26amp...";
如何使用 NSRegularExpression 从字符串中提取单词KEYWORD ?
我在 iOS SDK 4.2 上尝试了以下 NSRegularExpression,但它无法找到文本。下面的代码看起来没问题吗?
NSRegularExpression *testRegex = [NSRegularExpression regularExpressionWithPattern:@"(?<=href=\"\\/functions\\?q=).+?(?=\\x26amp])" options:0 error:nil];
NSRange result = [testRegex rangeOfFirstMatchInString:test options:0 range:NSMakeRange(0, [test length])];