小编Jul*_*uin的帖子

在 C# 中用 <br/> 替换 \n

我在将 \n 转换为 < br/> 时遇到问题。我要转换的文本是test\ntest\n\ntest 我希望它像test<br />test<br /><br />test. 所以每个 \n 都需要替换为<br />.

现在我正在使用此代码:

Regex regex = new Regex(@"(\n)+");
string ticketCategorieOmschrijving = regex.Replace("test\ntest\n\ntest", "<br />");
Run Code Online (Sandbox Code Playgroud)

但是此代码替换\n\n为单个<br />,而它需要<br /><br />

有人可以帮忙吗?

html c#

1
推荐指数
1
解决办法
232
查看次数

标签 统计

c# ×1

html ×1