日期:2014-05-18 浏览次数:20464 次
string source = @"<div id=""a"" class=""b"">"; Regex reg = new Regex(@"(id=""\S*"")|(class=""\S*"")"); source = reg.Replace(source, "");
------解决方案--------------------
static void Main(string[] args) { string str = @"<div id=""a"" class=""b""> <ul class=""m""> <table> <tr class=""on"" id=""role"">"; Regex re = new Regex(@"(id=""[^""]+"")|(class=""[^""]+"")", RegexOptions.None); str = re.Replace(str, ""); Console.WriteLine(str); Console.ReadLine(); }