0

我有以下 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 错误

有什么帮助吗?

4

1 回答 1

2
NSString *str = @"This is a test String*This a test string";
NSString *str2 = [str stringByReplacingOccurrencesOfString:@"*" withString:@"\n"];
NSLog(@"%@", str2);

如果这样的字符串, replace \n,那么结果是:

This is a test String
This a test string
于 2013-06-27T01:59:16.257 回答