- 积分
- 40165
- 好友
- 记录
- 主题
- 帖子
- 听众
- 收听
|
<input name="" value="">
<input name="a" value="12313">
类似于这样的标签
代码如下
[code=csharp]private static void TestRegex24()
{
string html1 = "<input value=\"bb\" name=\"aa\"> ";
string html2 = "<input title=\"xxa\" name=\"sss\" value=\"dd\" dgsd=\"xxx\">";
string html3 = "<input type=\"hidden\" name=\"source\" value=\"\" /> ";
string html = html1 + html2 + html3;
MatchCollection mc = Regex.Matches(html, @"(?is)<input.*?(?:name[^=]*=.*?(['""]?)(?<name>[^'"" ]*)\1|value[^=]*=.*?(['""]?)(?<value>[^'""]*?)\2| |.)+?>");
foreach (Match m in mc)
{
Console.WriteLine("name is : " + m.Groups["name"].Value);
Console.WriteLine("value is : " + m.Groups["value"].Value);
}
}[/code]
|
|