LightNight LightNight - 3 months ago 42
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"



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