也就是说,要找type为button的所有ID.文本如下:
<html>
<body>
<input id="button1" type="button">
<intpu id="button2" type="input">
<input id ="button3" type="button">
<input id="button4" type ="submid">
<input id="button5" type="button">
</body>
</html>
<html>
<body>
<input id="button1" type="button">
<intpu id="button2" type="input">
<input id ="button3" type="button">
<input id="button4" type ="submid">
<input id="button5" type="button">
</body>
</html>
解决方案 »
- “object”未包含“get_Range”的定义
- C#里的"特性"(Attribute)也太不讲理了吧!
- C#From窗体变大
- 如何获得下拉框已选值
- c# 如何判断网址是否为有效的网址
- 数字 名称 'System.Web.UI.WebControls' 包含的前缀数目超过了最大值。最大值为 3。这是个什么错误啊?
- 关于邮件发送的问题
- c#中类的数组进行赋值 如何让两个数组的值不关联 就是地址不相同
- 如何用C#代码修改或者添加开机密码,修改添加用户名,然后强制关机,求思路
- 执行SQL语句;
- 用AxImp.exe转换wmp的ActiveX控件是发生错误,高手来看看啊!
- treeview节点和数据库互操作
string regexStr = "id=\"(?<id>[^\"]+)\" type=\"button\"";
Regex regex = new Regex(regexStr, RegexOptions.IgnoreCase); //忽略大小写
string yourStr = @"<html>
<body>
<input id="button1" type="button">
<intpu id="button2" type="input">
<input id ="button3" type="button">
<input id="button4" type ="submid">
<input id="button5" type="button">
</body>
</html>";MatchCollection mc = regex.Matches(yourStr);
foreach(Match m in mc)
{
string temp = m.Group["id"].Value;
}
"(?<id>[^\"]+)\
谢谢!
(?<id>[^\"]+)
表示:
将非"的值加入名为id的组中。整个"id=\"(?<id>[^\"]+)\" type=\"button\""表示:
"
id=
\"
(?<id>[^\"]+)
\" type=
\"
button
\"
"