problem in retrieving string
I have array whic开发者_如何转开发h has string like..
"Turn left onto <b>Sri Krishna Nagar Rd</b><div class=\"google_note\">Pass by <b landmarkid=\"0x39ed58475c24020f:0x170a2130a5880d5a\" class=\"dir-landmark\">California Academy of Visual Effects</b> <div class=\"dirseg-sub\">(on the left)</div>\n</div>"
The above value I got from JSON.Now,how can I get string in the following format.
Turn left onto Sri Krishna Nagar Rd
Pass by California Academy of Visual Effects (on the left)
Thanx in advance.
USE this
NSString *str =@"Turn left onto <b>Sri Krishna Nagar Rd</b><div class=\"google_note\">Pass by <b landmarkid=\"0x39ed58475c24020f:0x170a2130a5880d5a\" class=\"dir-landmark\">California Academy of Visual Effects</b> <div class=\"dirseg-sub\">(on the left)</div>\n</div>";
str = [str stringByReplacingOccurrencesOfString:@"\\r\\n" withString:@""];
NSRange r;
while ((r = [str rangeOfString:@"<[^>]+>" options:NSRegularExpressionSearch]).location != NSNotFound)
str = [str stringByReplacingCharactersInRange:r withString:@""];
NSLog(@"%@",str);
Why you want that string in that format? do you want to load that return string from JSON inside UIWebView ? if yes then you can simply call loadHtmlString method by appending "<"html>.."<"/html>"
精彩评论