NSString *pattern = @"<script type=\"text/json\" id=\"disqus-threadData\">([^\"]+)</script>";
NSString *pattern = @"<script type=\"text/json\" id=\"disqus-threadData\">(.*?)</script>";
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;
}