NSString *qwer2 = [qwer1 stringByReplacingOccurrencesOfString:@"count '0','" withString:@""];
NSString *qwer4 = [qwer2 stringByReplacingOccurrencesOfString:@"count '1','" withString:@""];
NSString *qwer = [qwer4 stringByReplacingOccurrencesOfString:@"count '2','" withString:@""];
如何用任意数字替换字符串?
count '0' , count '1' , count '2'
count 'any numbers'
我已经尝试过循环:
for (int i =0; i<100; i++)
NSString *qwer = [qwer4 stringByReplacingOccurrencesOfString:@"count 'i','"withString:@""];
最佳答案
NSString *replaced = [string stringByReplacingOccurrencesOfString:@"count '\\d+','"
withString:@""
options:NSRegularExpressionSearch
range:NSMakeRange(0, string.length)];
应该可以解决问题。 “\d+”是匹配一个或多个数字的正则表达式模式。
关于objective-c - stringByReplacingOccurrencesOfString 循环?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21933632/