gpt4 book ai didi

dart - 如何从 Dart 中的字符串中删除换行符?

转载 作者:行者123 更新时间:2023-12-04 13:42:16 24 4
gpt4 key购买 nike

如何从 Dart 中的字符串中删除换行符?

例如,我想转换:

"hello\nworld"


"hello world"

最佳答案

您可以使用 replaceAll(pattern, replacement):

main() {
var multiline = "hello\nworld";
var singleline = multiline.replaceAll("\n", " ");
print(singleline);
}

关于dart - 如何从 Dart 中的字符串中删除换行符?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11053114/

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