正则表达式
以一个变量开头开头,以</from>结尾例如变量 string action="action="http://dafsd.com/post.aspx";
我想获取action开头到</from>结束直接的字符第二个我想获取页面<input  class="bComment" size="40" type="text" name="u" id="u" />包括type="text"的所有数据集合,获取出来结果为<input  class="bComment" size="40" type="text" name="u" id="u" />

解决方案 »

  1.   

    1.楼主需要js正则,还是C#后台正则.2.另外建议楼主从新陈述下问题
      

  2.   

    第二个不需要正则就可实际.遍历页面里的控件,找到type为text的就可以了。。第一个看着不明白。。
      

  3.   

    我需要的是C#正则表达式
    例如变量 string action="action="http://dafsd.com/post.aspx";
    我想获取action开头到</from>结束之间的字符第二个我想获取所有包含type="text"字符的控件例如我要获取的结果是
    <input class="bComment" size="40" type="text" name="u" id="u" /><input size="40" type="text" id="b"  /><input size="40" type="text" id="c"  />
    我要获取这些集合
      

  4.   

    我要通过c# 正则表达式解析HTML字符串
      

  5.   


    Match m = Regex.Matches(原字符串, 
    @"(?<=action=\")[^<]+",RegexOptions.IgnoreCase);
    if (m.Success) string action=m;string input;
    MatchCollection matches = Regex.Matches(原字符串, 
    @"<.{0,2}input[^>]+type.{0,3}text[^>]+>",RegexOptions.IgnoreCase);
     foreach(Match match in matches)
    {
    xxx+==match.ToString();
    }
      

  6.   

    第一个:@"action[\s\S]+?</form>"第二个:"<.+?type=\"text\".+?>"我用的是RCRE的正则, 不知道可以否, 你可以试试
      

  7.   

    小毛病更正一下string action="";
    Match m = Regex.Match(原字符串, "(?<=action=\")[^>\"]+",RegexOptions.IgnoreCase);
    if (m.Success) action=m.ToString();string inputs="";
    MatchCollection matches = Regex.Matches(原字符串,"<.{0,2}input[^>]+type.{0,3}text[^>]+>",RegexOptions.IgnoreCase);
    foreach(Match match in matches)
    {
    inputs+=match.ToString();
    }
      

  8.   

    1、
    string action = Regex.Escape("action=\"http://dafsd.com/post.aspx");
    Regex reg = new Regex(@"(?is)" + action + "(.*?)</from>");
    MatchCollection mc = reg.Matches(yourStr);
    foreach (Match m in mc)
    {
       richTextBox2.Text += m.Groups[1].Value + "\n";
    }2、
    Regex reg = new Regex(@"<input[^>]*?type=""text""[^>]*>");
    MatchCollection mc = reg.Matches(yourStr);
    foreach (Match m in mc)
    {
       richTextBox2.Text += m.Value + "\n";
    }
      

  9.   

    谢谢你们,还有一个我要找这样格式的集合类型刚才type="text" 哪个方式
    <textarea cols="40" class="bComment" name="p" id="p" rows="10"></textarea>
    请在帮忙下,谢谢
      

  10.   

    还有,我想获取<textarea cols="40" class="bComment" name="p" id="p" rows="10"></textarea>
    这个字符里面的name的值和ID的值,用正则表达式怎么获取?