iOS 去除字符串中用括号括住的位置

2016-12-08  本文已影响133人  香蕉你个菠萝

直接上代码

-(NSString*)handleStringWithString:(NSString*)str{

NSMutableString* muStr = [NSMutableStringstringWithString:str];

while(1) {

NSRangerange = [muStrrangeOfString:@"("];

NSRangerange1 = [muStrrangeOfString:@")"];

if(range.location!=NSNotFound) {

NSIntegerloc = range.location;

NSIntegerlen = range1.location- range.location;

[muStrdeleteCharactersInRange:NSMakeRange(loc, len +1)];

}else{

break;

}

}

returnmuStr;

}

上一篇下一篇

猜你喜欢

热点阅读