也就是说,要找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>

解决方案 »

  1.   

    文本读入String,然后查找这还不容易嘛
      

  2.   

    正则表达式
    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;
    }
      

  3.   

    有没有人帮忙解释一下这一段呢?
          "(?<id>[^\"]+)\
    谢谢!
      

  4.   

    自己看了看regular expression,
       (?<id>[^\"]+)
    表示:
       将非"的值加入名为id的组中。整个"id=\"(?<id>[^\"]+)\" type=\"button\""表示:
      "
        id=
        \"
          (?<id>[^\"]+)
        \"     type=
        \"
           button
        \"
      "