Skip to content

Instantly share code, notes, and snippets.

@jcromartie
Forked from anthonycvella/gist:5490481
Last active December 16, 2015 20:10
Show Gist options
  • Save jcromartie/5490630 to your computer and use it in GitHub Desktop.
Save jcromartie/5490630 to your computer and use it in GitHub Desktop.
- (IBAction)btnConvert:(id)sender {
NSString *urlString = urlField.text;
answerData = [NSData dataWithContentsOfURL:[NSURL URLWithString:urlString]];
html = [[NSString alloc] initWithData:answerData encoding:NSUTF8StringEncoding];
NSLog(@"Source: %@", html);
NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:@"ansMap\\[\\d+\\] = '(\\w+)'" options:0 error:NULL];
[regex enumerateMatchesInString:html options:0 range:NSMakeRange(0, [html length]) usingBlock:^(NSTextCheckingResult *result, NSMatchingFlags flags, BOOL *stop) {
NSRange range = [result rangeAtIndex:1];
NSString *answer = [html substringWithRange:range];
// do whatever you want with answer
}];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment