-
-
Save jcromartie/5490630 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (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