您的位置:首页 > 编程语言 > C#

C# 正则表达式替换换行

2013-11-28 17:52 281 查看
将换行替换成"\n"字符,如下:

代码一:

string strContent = txtNote.Text;
strContent = Regex.Replace(strContent, "\r\n", "\\n");


代码二:

string strContent = txtNote.Text;
Regex regex = new Regex("\r\n");
strContent = regex.Replace(strContent, "\\n");
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: