我的正则表达式:@"<input[^>]*?(name=""(?<name1>\w+)"")*?type=""(hidden|text)""(name=""(?<name2>\w+)"")*?(value=(?<value>\w*))*?[^>]*>"
匹配出来的项:'<input name="sAreaValue" type="hidden" id="sAreaValue" value="1|0" />'
然后我用foreach (Match inputMatch in inputMatchs)
        {
            GroupCollection inputGroupCollection = inputMatch.Groups;
            string inputText = inputMatch.Value;
            string value = inputGroupCollection["value"].Value;
            string name= inputGroupCollection["name1"].Value;
        }为什么name与value没有值呢?请大牛帮忙 

解决方案 »

  1.   

    <input name="sAreaValue" type="hidden" id="sAreaValue" value="1|0" />'
    html控件要后台获取加runat="server"
      

  2.   

    html也可以加的 不过这样就和.net的控件一样的了
      

  3.   


    <input>控件 当然有啊  在<input>里面加
    runat="server"  就能后台调用了!··
      

  4.   


    <input.*?name="(?<name1>\w+)".*?type="(hidden|text)".*?value="(?<value>\S+)"[^>]*?>
      

  5.   

    我晕,我是在匹配aspx的HTML源码
      

  6.   

    string str=@"<input[^>]+name=""(?<name>[^""]+)""[^>]+value=""(?<value>[^""]+)";
      

  7.   

    你这正则有问题,应该是中间的匹配不到,试试这个:(?i)<input[^>]*?(?=name="(?<name>[^"]*)")[^>]*?(?=type="(hidden|text)")[^>]*?(?=value="(?<value>[^"]*)")[^>]*>
      

  8.   

    如果要name type value 无序的,如下:
    (?i)<input(?=[^>]*?(?:name="(?<name>[^"]*)"))(?=[^>]*?(?:type="(?:hidden|text)"))(?=[^>]*?(?:value="(?<value>[^>]*)"))[^>]*>
      

  9.   

    string str=@"<input[^>]+name=""(? <name>[^""]+)""[^>]+type=""(hidden|text)""[^>]+value=""(? <value>[^""]+)"; 
      

  10.   

    try...string test = "<input name=\"sAreaValue\" type=\"hidden\" id=\"sAreaValue\" value=\"1|0\" />";
    Regex reg = new Regex(@"(?is)<input(?>(?:name=""(?<name>[^""]*)""|value=""(?<value>[^""]*)""|type=""(?<type>hidden|text)""|[^>])*)(?(name)|(?!))(?(value)|(?!))(?(type)|(?!))>");
    MatchCollection mc = reg.Matches(test);
    foreach (Match m in mc)
    {
        richTextBox2.Text += m.Groups["name"].Value + "\n";
        richTextBox2.Text += m.Groups["value"].Value + "\n";
    }