我有以下NSString:
"This is a test String
*This a test string"
我想用这样的回报替换“*”
"This is a test string
This is a test string"
我试过了:
[removeStr stringByReplacingOccurrencesOfString:@"*" withString:@"/r"];
但它打印“/ r”,当我尝试“\ r”时,我得到一个lldb错误
任何帮助?
答案 0 :(得分:2)
NSString *str = @"This is a test String*This a test string";
NSString *str2 = [str stringByReplacingOccurrencesOfString:@"*" withString:@"\n"];
NSLog(@"%@", str2);
如果字符串如此,则替换\n
,结果为:
This is a test String
This a test string