LightNight LightNight - 1 year ago 100
Objective-C Question

Change html tag in NSString

For example I have html string:

<img mce_src="" src="" width="512" height="512" style="">
<br mce_bogus="1">

How can I change this properties:
width="512" height="512"
to for example:
width="123" height="123"


Answer Source

You should go with regular expressions and try the RegexKitLite library.

NSString *regex = @"(=\"[0-9]+\")";

NSString *replaced = [htmlString stringByReplacingOccurrencesOfRegex:regex usingBlock:^NSString *(NSInteger captureCount, NSString * const capturedStrings[captureCount], const NSRange capturedRanges[captureCount], volatile BOOL * const stop) {
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download