iOS
- 1 ответ
- 0 вопросов
1
Вклад в тег
int main () {
NSFileHandle *handle = [NSFileHandle fileHandleForReadingAtPath:@"/Users/byss/Downloads/test.html"];
NSString *haystack = [[NSString alloc] initWithData:[handle readDataToEndOfFile] encoding:NSUTF8StringEncoding];
NSRegularExpression *re = [[NSRegularExpression alloc] initWithPattern:@"<script type=\"text/json\" id=\"disqus-threadData\">(.+?)</script>" options:NSRegularExpressionCaseInsensitive error:nil];
[re enumerateMatchesInString:haystack options:0 range:NSMakeRange (0, haystack.length) usingBlock:^(NSTextCheckingResult *result, NSMatchingFlags flags, BOOL *stop) {
if (result.numberOfRanges == 2) {
NSLog (@"%@", [haystack substringWithRange:[result rangeAtIndex:1]]);
}
}];
return 0;
}