标签:
//在字符串sting1 中将所有string2 替换成string3
-(NSString *)stringByReplacingCharactersInRangeString:(NSString *)string1 andString:(NSString *)string2 andorString:(NSString *)string3{
NSUInteger cnt = 0, length = [string1 length];
NSRange range = NSMakeRange(0, length);
while(range.location != NSNotFound)
{
range = [string1 rangeOfString: string2 options:0 range:range];
if(range.location != NSNotFound)
{
string1 = [string1 stringByReplacingCharactersInRange:range withString:string3];
range = NSMakeRange(range.location + range.length, length - (range.location + range.length));
cnt++;
}
}
return string1;
}
标签:
原文地址:http://www.cnblogs.com/Lzhou/p/5257926.html