我有一些文本(例如“o\nour first place, and this\n\n13”),我希望文本中的每个“\n”字符串都必须用换行符替换...
该示例的输出将是:
o 我们的第一名,还有这个
13 我怎么做?文本框是多行的
代码是
string text_str = txtbox.Text;
text_str .Replace("(?<!\r)\n", "\r\n");
txtbox.Clear();
txtbox.Text = text_str;
Run Code Online (Sandbox Code Playgroud)