My complete work for you in a free time.
String HTMLStr = "<ul><li><u><em><strong>Hi </strong></em></u></li><li><u><em><strong>Hello </strong></em></u></li> <li><u><em><strong>How r u. </li></ul>";
Regex regex = new Regex("\\<[^\\>]*\\>");
MatchCollection collection = regex.Matches(HTMLStr);
List<coll> list = new List<coll>();
foreach (Match match in collection)
{
list.Add(new coll() { POS = match.Index, TAG = match.Value.ToString() });
}
for (int i = 0; i < collection.Count / 2; i++)
{
bool temp = false;
foreach (coll col in list)
{
if (!col.TAG.Contains("/"))
{
foreach (coll col1 in list)
{
if (col1.TAG.Contains("/"))
{
if (col.TAG.Replace(" ", "") == col1.TAG.Replace("/", "").Replace(" ", ""))
{
list.Remove(col);
list.Remove(col1);
temp = true;
break;
}
}
}
}
if (temp)
break;
}
}
foreach (coll col in list)
{
HTMLStr = HTMLStr.Remove(col.POS, col.TAG.Length);
}
Class coll
public class coll
{
public int POS {get;set;}
public string TAG {get;set;}
}