Files
Yi.Framework/Yi.Furion.Rbac/Yi.Framework.Infrastructure/Helper/HtmlHelper.cs
2023-04-13 21:12:06 +08:00

25 lines
788 B
C#

namespace Yi.Framework.Infrastructure.Helper
{
public static class HtmlHelper
{
#region HTML标签
/// <summary>
/// 去除富文本中的HTML标签
/// </summary>
/// <param name="html"></param>
/// <param name="length"></param>
/// <returns></returns>
public static string ReplaceHtmlTag(string html, int length = 0)
{
string strText = System.Text.RegularExpressions.Regex.Replace(html, "<[^>]+>", "");
strText = System.Text.RegularExpressions.Regex.Replace(strText, "&[^;]+;", "");
if (length > 0 && strText.Length > length)
return strText.Substring(0, length);
return strText;
}
#endregion
}
}