开发者

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>"

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜