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

2017-11-14  本文已影响14人  i_MT

#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;

}

上一篇下一篇

猜你喜欢

热点阅读