iOS 过滤字符串好用到没话说

#pragma mark ----------- ---------去除字符串中的标点符号

-(NSString*) stringDeleteString:(NSString*)str

{

NSMutableString*str1 = [NSMutableStringstringWithString:str];

for(inti =0; i < str1.length; i++)

{

unicharc = [str1characterAtIndex:i];

NSRangerange =NSMakeRange(i,1);

if(c =='"'|| c =='.'|| c ==','|| c ==' '|| c =='\n'|| c =='('|| c ==')'|| c =='{'|| c =='}')//此处可以是任何字符

{

[str1deleteCharactersInRange:range];

--i;

}

}

NSString*newstr = [NSStringstringWithString:str1];

returnnewstr;

}

你可能感兴趣的:(iOS 过滤字符串好用到没话说)