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);

そのような文字列の場合、 を置換\nすると、結果は次の ようになります。

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