【问题标题】:How to remove new lines in a string using the processing language?如何使用处理语言删除字符串中的新行?
【发布时间】:2013-03-24 14:18:48
【问题描述】:

是否可以从正在处理的字符串中删除换行符('\n')。

例如

'hello,
how are you,
that's nice.'

变成

'hello, how are you, that's nice'

谢谢

【问题讨论】:

  • 您是否希望使用任何特定的语言来执行此操作?

标签: string text newline processing


【解决方案1】:

由于它基于 Java,您可以使用 String API 中的所有方法。例如:

String s = "hello,\nhow are you,\nthat's nice.";
s = s.replace('\n', ' ');
println(s);

【讨论】:

    猜你喜欢
    • 2014-07-18
    • 2014-11-16
    • 2011-03-14
    • 1970-01-01
    • 1970-01-01
    • 2023-03-08
    • 1970-01-01
    • 1970-01-01
    • 2022-01-10
    相关资源
    最近更新 更多