Home > Net >  Regular filter a tag but retains the href attribute
Regular filter a tag but retains the href attribute

Time:12-04

The following code is this online to find clean up HTML redundant code, run no problem also can achieve the effect, but wants to keep the specific label specific attributes, such as a tag reserves the href attribute, img tags to retain the SRC, width, height, Alt attributes, td and th labels retain colspan, rowspan attributes, such as
Also want to use regular have replaced all div tags with p label, also please great god rescue,
 
Public static string ClearElement (string STR, string element)
{
String old=@ & lt; "" Element + + "[^ & gt;] + & gt; ";
String rep="& lt;" Element + + & gt; "";
STR=Regex. Replace (STR, old, rep, RegexOptions IgnoreCase);
return str;
}
  •  Tags:  
  • C#
  • Related