/// <summary> /// 替换换行符 /// </summary> /// <param name="str"></param> /// <returns></returns> public string ReplaceToHTML(string str) { if (string.IsNullOrEmpty(str)) { return str; } str = System.Text.RegularExpressions.Regex.Replace(str, @"\r\n", "<br/>"); str = System.Text.RegularExpressions.Regex.Replace(str, @"\n", "<br/>"); return str; } /// <summary> /// 还原换行符 /// </summary> /// <param name="str"></param> /// <returns></returns> public string ReductionReplace(string str) { if (string.IsNullOrEmpty(str)) { return str; } str = System.Text.RegularExpressions.Regex.Replace(str, @"<br/>", "\n"); return str; }