Hey All,
I have an app that gets some returned data from a website and stores it in an NSString. The returned data is HTML with some information I want to get that's dynamic (it's always different when the data is returned). The stuff I'm looking for is buried within the HTML in lines like this:
<td align="center" colspan="1"> <a class="ada" title="11:00 P.M.">11:00 P.M.</td><td align="left" colspan="1"> TO Some Destination</td>
I tried using an XML scanner, but it kept failing out with errors not liking the way the returned code was formatted I guess. After doing some Googling, it seems I should be using regular expressions to do a search through the string to find the data. I have this so far:
My problem is the regex expression which right now is @"", which obviously isn't what I want. I read about regular expressions, but still don't really know how to start? I should mention as well that there are normally multiple times and occasionally no times returned.
Any thoughts or help?
I have an app that gets some returned data from a website and stores it in an NSString. The returned data is HTML with some information I want to get that's dynamic (it's always different when the data is returned). The stuff I'm looking for is buried within the HTML in lines like this:
<td align="center" colspan="1"> <a class="ada" title="11:00 P.M.">11:00 P.M.</td><td align="left" colspan="1"> TO Some Destination</td>
I tried using an XML scanner, but it kept failing out with errors not liking the way the returned code was formatted I guess. After doing some Googling, it seems I should be using regular expressions to do a search through the string to find the data. I have this so far:
Code:
// create a regex to find the times in the returned string
NSRegularExpression *timeRegex = [[NSRegularExpression alloc] initWithPattern:@""
options:NSRegularExpressionCaseInsensitive error:nil];
// find an array of the times
NSArray *times = [timeRegex matchesInString:self.returnedDataString options:0 range:NSMakeRange(0, [self.returnedDataString length])];
My problem is the regex expression which right now is @"", which obviously isn't what I want. I read about regular expressions, but still don't really know how to start? I should mention as well that there are normally multiple times and occasionally no times returned.
Any thoughts or help?