0
点赞
收藏
分享

微信扫一扫

处理特殊字符和移掉内联样式


#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中的内联样式,方便自定义自己的统一样式。


举报

相关推荐

0 条评论