#region 处理特殊字符
public static string DisposalSpecial(string regexStr)
{
var regex = new Regex("([\\\\\\^\\$\\+\\?\\{\\}\\?\\(\\)\\!\\-\\[\\]\\+\\/])");
string rel = regex.Replace(regexStr, "\\$1");
rel= rel.Replace(" ", "\\s");
return rel;
}
#endregion
#region 移掉内联样式
public static string RemoveStyle(string html)
{
if (string.IsNullOrEmpty(html))
{
return string.Empty;
}
return Regex.Replace(html, "style=\\\"[\\s\\S]*?\\\"", string.Empty, RegexOptions.IgnoreCase);
}
#endregion
通过上述方法,可以移除html中的内联样式,方便自定义自己的统一样式。
处理特殊字符和移掉内联样式
最新推荐文章于 2022-04-21 14:44:38 发布