gpt4 book ai didi

ios:用返回替换 NSString 中的单词

转载 作者:行者123 更新时间:2023-11-28 22:31:25 25 4
gpt4 key购买 nike

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

有什么帮助吗?

最佳答案

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

关于ios:用返回替换 NSString 中的单词,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17333300/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com