NSString *str = @"<p>讨厌的</p>节点<br/></pN>";
//除去字符串中的不想要的 //invertedSet 将去除的反过来变成不去除的
NSCharacterSet *characterSet = [[NSCharacterSet characterSetWithCharactersInString:@"<p/brh>"] invertedSet];
NSString *filtered = [[str componentsSeparatedByCharactersInSet:characterSet] componentsJoinedByString:@""];
//去除两端的空格
NSString *newString = [filtered stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
NSLog(@"%@",newString);
版权声明:本文为博主原创文章,未经博主允许不得转载。
时间: 2024-11-08 20:55:16