I am attempting to get my school's notification shown on app. Here is the source code of the HTML of notification.
<div id="tab1_bottom" key="l7ob6tgg-0oe4-hbkw-7gdr-0vddvv41qbsd">
<div class="tab1_bottom1" title="上海廿一客食品2018校园宣讲会">上海廿一客食品2018校园宣讲会</div>
<div class="tab1_bottom2" title="专场宣讲会">专场宣讲会</div>
<div class="tab1_bottom3">2017-11-13</div>
<div class="tab1_bottom4">15:30-17:30</div>
<div class="tab1_bottom5" title="叶耀珍楼202">叶耀珍楼202</div>
</div>
My action: Use NSURLSessionDataTask to get HTML, and saved as htmlstring. Then, I use NSRegularExpression+"(AA)(.*?)(BB)" to extract the htmlstring for the information I want.
NSString *htmlstring = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:@"(1\" title=\")(.*?)(\">)" options:0 error:nil];
NSArray *matches = [regex matchesInString:htmlstring options:0 range:NSMakeRange(0,htmlstring.length)];
for(NSTextCheckingResult *result in [matches objectEnumerator]) {
NSRange matchRange1 = [result range];
NSString *newStr1=[htmlstring substringWithRange:matchRange1];
NSLog(@"%@",newStr1);
}
Q1:what finally I got were "(AA)(.?)(BB)", but I just want "(.?)", not AABB. How to fix it ?
Q2:I hope to save newStr1 as a Array and write it on UILabel. However, what I now got was a String, not a Array. I cannot write it on my TableView Label.
What I want shown on my table is just like this https://github.com/AlexLLL/MyFudanCampus/blob/master/MyFudanCampus/screenshots/Simulator%20Screen%20Shot%20-%20iPhone%208%20Plus%20-%202017-11-12%20at%2022.07.57.png