使用正则表达式,发现在你的字符串中的配衬,并删除它们! 下面是如何
NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:@"]*>"
options:NSRegularExpressionCaseInsensitive
error:nil];
NSMutableString* mutableString = [yourStringToStripFrom mutableCopy];
NSInteger offset = 0; // keeps track of range changes in the string due to replacements.
for (NSTextCheckingResult* result in [regex matchesInString:yourStringToStripFrom
options:0
range:NSMakeRange(0, [yourStringToStripFrom length])]) {
NSRange resultRange = [result range];
resultRange.location += offset;
NSString* match = [regex replacementStringForResult:result
inString:mutableString
offset:offset
template:@"$0"];
// make the replacement
[mutableString replaceCharactersInRange:resultRange withString:@""];
// update the offset based on the replacement
offset += ([replacement length] - resultRange.length);
}