ios 正則表達式替换

时间:2022-05-21 03:41:43

1. 不可变字符串   (content 是不可变)

NSRegularExpression *regularExpression = [NSRegularExpression
regularExpressionWithPattern:

@"<(/{0,})div(.{0,})>"
options:0 error:nil];

content  = [regularExpression stringByReplacingMatchesInString:content
options:0
range:NSMakeRange(0, content.length)
withTemplate:@""];

1. 可变字符串   (content 是可变)

[regularExpression replaceMatchesInString:content options:0 range:NSMakeRange(0,
content.length) withTemplate:@""];