日期:2014-05-17 浏览次数:20500 次
string html = @"<input id='ss' type='hidden' value='2'/>"; MatchCollection mc = Regex.Matches(html, @"(?is)<input.*?(?:name[^=]*=.*?(['""]?)(?<name>[^'"" ]*)\1|value[^=]*=.*?(['""]?)(?<value>[^'""]*?)\2|type[^=]*=.*?(['""]?)(?<type>[^'""]*?)\3|id[^=]*=.*?(['""]?)(?<id>[^'""]*?)\4|.)+?>"); foreach (Match m in mc) { Console.WriteLine("id is : " + m.Groups["id"].Value); Console.WriteLine("name is : " + m.Groups["name"].Value); Console.WriteLine("value is : " + m.Groups["value"].Value); Console.WriteLine("type is : " + m.Groups["type"].Value); }