又是正则表达式 if you don't need to match those attributes, you can do<table[^>]*> 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 to saucer(思归, MS .NET MVP):我是想除了我上面写的属性之外,如果再有别的东西,比如onclick我是不会匹配的,怎么办,你的方法连onclik都匹配了 帮帮忙吧,本人的另外一个贴的分也可以给他:http://expert.csdn.net/Expert/topic/2097/2097696.xml?temp=.5310938同一个问题 if you want to match everything, trystring[] slist = {"<table width=\"100%\" height=\"\" border=\"0\" style=\"\" cellpadding=\"0\" cellspacing=\"0\">", "<table>","<table border=\"1\" >", "<table border=\"1\" width=\"100%\" test=\"ss\" >", "<table test=\"ss\" border=\"1\" width=\"100%\" >" } ;Regex re = new Regex(@"<table(?:[^>]*?(?:width=""(?<width>[^""]*)""|height=""(?<height>[^""]*)""|border=""(?<border>[^""]*)""|style=""(?<style>[^""]*)""|cellpadding=""(?<cellpadding>[^""]*)""|cellspacing=""(?<cellspacing>[^""]*)""))*[^>]*?>", RegexOptions.IgnoreCase | RegexOptions.Singleline);foreach (string s in slist){ Console.WriteLine("\nfor:\t{0}\n",s);Match m = re.Match(s);if (m.Success){ Console.WriteLine("width:{0}",m.Groups["width"].Value); Console.WriteLine("height:{0}",m.Groups["height"].Value); Console.WriteLine("border:{0}",m.Groups["border"].Value); Console.WriteLine("style:{0}",m.Groups["style"].Value); Console.WriteLine("cellpadding:{0}",m.Groups["cellpadding"].Value); Console.WriteLine("cellspacing:{0}",m.Groups["cellspacing"].Value);}}if you just want what you listed it, trystring[] slist = {"<table width=\"100%\" height=\"\" border=\"0\" style=\"\" cellpadding=\"0\" cellspacing=\"0\">", "<table>","<table border=\"1\" >", "<table border=\"1\" width=\"100%\" test=\"ss\" >", "<table test=\"ss\" border=\"1\" width=\"100%\" >" } ;Regex re = new Regex(@"<table(?:\s*(?:width=""(?<width>[^""]*)""|height=""(?<height>[^""]*)""|border=""(?<border>[^""]*)""|style=""(?<style>[^""]*)""|cellpadding=""(?<cellpadding>[^""]*)""|cellspacing=""(?<cellspacing>[^""]*)""))*\s*>", RegexOptions.IgnoreCase | RegexOptions.Singleline);foreach (string s in slist){ Console.WriteLine("\nfor:\t{0}\n",s);Match m = re.Match(s);if (m.Success){ Console.WriteLine("width:{0}",m.Groups["width"].Value); Console.WriteLine("height:{0}",m.Groups["height"].Value); Console.WriteLine("border:{0}",m.Groups["border"].Value); Console.WriteLine("style:{0}",m.Groups["style"].Value); Console.WriteLine("cellpadding:{0}",m.Groups["cellpadding"].Value); Console.WriteLine("cellspacing:{0}",m.Groups["cellspacing"].Value);}} 如何实现 gridview添加一行数据后,在左边的treeview上同步显示出来??? 请问清空Session会不会将其他用户的Session清空 给GridView添加滚动条 怎么实现中英双语言 如何获取页面的IMAGE控件的图片 cache 关于ascx控件使用的一个小小问题,请大伙帮忙~ 求关于动态验证页面内控件是否显示的问题(c#.net)(在线等待) to:guoyan19811021,太谢谢了! 是不是ASP.NET 不赞成使用Response.write 向客户发送信息? 发布asp.net程序要发布那几个文件,不发布源码 帮我看看吧,让我郁闷一天的正则表达式
我是想
除了我上面写的属性之外,如果再有别的东西,比如onclick我是不会匹配的,
怎么办,你的方法连onclik都匹配了
http://expert.csdn.net/Expert/topic/2097/2097696.xml?temp=.5310938同一个问题
string[] slist = {"<table width=\"100%\" height=\"\" border=\"0\" style=\"\" cellpadding=\"0\" cellspacing=\"0\">",
"<table>","<table border=\"1\" >", "<table border=\"1\" width=\"100%\" test=\"ss\" >",
"<table test=\"ss\" border=\"1\" width=\"100%\" >"
}
;
Regex re = new Regex(@"<table(?:[^>]*?(?:width=""(?<width>[^""]*)""|height=""(?<height>[^""]*)""|border=""(?<border>[^""]*)""|style=""(?<style>[^""]*)""|cellpadding=""(?<cellpadding>[^""]*)""|cellspacing=""(?<cellspacing>[^""]*)""))*[^>]*?>", RegexOptions.IgnoreCase | RegexOptions.Singleline);
foreach (string s in slist)
{
Console.WriteLine("\nfor:\t{0}\n",s);
Match m = re.Match(s);
if (m.Success)
{
Console.WriteLine("width:{0}",m.Groups["width"].Value);
Console.WriteLine("height:{0}",m.Groups["height"].Value);
Console.WriteLine("border:{0}",m.Groups["border"].Value);
Console.WriteLine("style:{0}",m.Groups["style"].Value);
Console.WriteLine("cellpadding:{0}",m.Groups["cellpadding"].Value);
Console.WriteLine("cellspacing:{0}",m.Groups["cellspacing"].Value);}
}
if you just want what you listed it, try
string[] slist = {"<table width=\"100%\" height=\"\" border=\"0\" style=\"\" cellpadding=\"0\" cellspacing=\"0\">",
"<table>","<table border=\"1\" >", "<table border=\"1\" width=\"100%\" test=\"ss\" >",
"<table test=\"ss\" border=\"1\" width=\"100%\" >"
}
;
Regex re = new Regex(@"<table(?:\s*(?:width=""(?<width>[^""]*)""|height=""(?<height>[^""]*)""|border=""(?<border>[^""]*)""|style=""(?<style>[^""]*)""|cellpadding=""(?<cellpadding>[^""]*)""|cellspacing=""(?<cellspacing>[^""]*)""))*\s*>", RegexOptions.IgnoreCase | RegexOptions.Singleline);
foreach (string s in slist)
{
Console.WriteLine("\nfor:\t{0}\n",s);
Match m = re.Match(s);
if (m.Success)
{
Console.WriteLine("width:{0}",m.Groups["width"].Value);
Console.WriteLine("height:{0}",m.Groups["height"].Value);
Console.WriteLine("border:{0}",m.Groups["border"].Value);
Console.WriteLine("style:{0}",m.Groups["style"].Value);
Console.WriteLine("cellpadding:{0}",m.Groups["cellpadding"].Value);
Console.WriteLine("cellspacing:{0}",m.Groups["cellspacing"].Value);}
}