あなたが使用することができます
- (NSString *)stringByReplacingOccurrencesOfString:(NSString *)target
withString:(NSString *)replacement
htmlを使用した例htmlString
htmlString = [htmlString stringByReplacingOccurrencesOfString:@"width=\"512\""
withString:@"width=\"123\""];
編集:
正規表現の置換を使用する (テストされていません):
NSError *error = NULL;
NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:@"(.*width=\").*?(\".*?height=\").*?(\".*)"
options:NSRegularExpressionCaseInsensitive
error:&error];
NSString *modifiedString = [regex stringByReplacingMatchesInString:htmlString
options:0
range:NSMakeRange(0, [htmlString length])
withTemplate:@"$1<insert width here>$2<insert height here>$3"];
参考:
NSRegularExpression