iCoder4777
iCoder4777

Reputation: 1692

problem in retrieving string

I have array which 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.

Upvotes: 0

Views: 61

Answers (2)

Narayana Rao Routhu
Narayana Rao Routhu

Reputation: 6323

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);

Upvotes: 1

Praveen-K
Praveen-K

Reputation: 3401

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

Upvotes: 0

Related Questions