1. 程式人生 > >ios 正則表示式替換

ios 正則表示式替換

1. 不可變字串   (content 是不可變)

NSRegularExpression *regularExpression = [NSRegularExpressionregularExpressionWithPattern:

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

 content  = [regularExpression stringByReplacingMatchesInString:content options:0range:NSMakeRange(

0, content.length) withTemplate:@""];

1. 可變字串   (content 是可變)

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