<td width="201">001:Aman'Thul   DE   A</td>
 <td width="201">002:Dalvengyr    DE       H</td>
<td width="201">003:Der Mithrilorden  DE    H</td>
<td width="201">004:Die Arguswacht  DE A</td>
<td width="201">008:Kult der Verdammten  DE   A</td>请问怎样提取Aman'Thul  ,Dalvengyr,Der Mithrilorden,Kult der Verdammten  到<area>  提取  H,A到<type>中..我现在的表达式:
[^:]*?:(?<area>[\S\s]+)\s+?(?<type>[HA]) 
不能满足..

解决方案 »

  1.   

    (<td[^>]+>)([^<]+)</td>
    Groups[1]=类似于“<td width="201">”这一段
    Groups[2]=就是你要的字符串
      

  2.   

    没看清楚要求
    (<td[^>]+>\d{3}:)([^<]+)</td>
    这个可以得到你想要的结果。
      

  3.   

    (<td[^>]+>\d{3}:)([^<]+)</td>
    正确
      

  4.   

    提取Aman'Thul  ,Dalvengyr,Der Mithrilorden,Kult der Verdammten  到<area>  提取  H,A到<type>中  啊
    单独的Aman'Thul   A
    然后 Dalvengyr  H

    Der Mithrilorden     H...........
      

  5.   

    兄弟,这个问题不是给你解答过吗<td[^>]*?>[^:]*?:(?<area>[\s\S]*?)\s*?DE\s*?(?<type>\b[HA]\b)</td>DE是固定的吗,不取到area里是吧,且它与[HA]之间只有空格吗
    呵呵,有正则问题直接PM我就行了,也不用浪费这些分了
      

  6.   

    (?<=\"201\").+?(?=<\/td>)
    将匹配得到的string1分成两段就是你要的。
    type=string1.Lastindexof(0);
    area=string1.Replace(type,"");
      

  7.   

    lxcnn(过客) ( ) 
    每事反正有分的嘛...
    ===============
    因为Hakkar 这里可能包含H或A,所以不能用[^HA],如果area里可能有回车,那就那.换成[\s\S],因为后面的H或A肯定存在,所以[HA]这样写就可以,但要判断一下两侧的条件,嗯,前面的\s*?还是用你的\s+好一点:\s*?(?<area>[\s\S]*?)\s+?(?<type>[HA])(?=\s|$)
    ============================================
    才看到上面的回复,那这样:\s*?(?<area>[\s\S]*?)\s+?(?<type>[HA])(?=<|\s|$)是几个单词无所谓,因为前面的“:”和后面的“[HA]”,已经把范围限定死了,只要把“[HA]”两侧的条件限定一下就行了
    ============================================
    或者这样写,就不用考虑“[HA]”后面的具体情况了:\s*?(?<area>[\s\S]*?)\s+?(?<type>\b[HA]\b)
    ===============================================这些就是你的回复啊..前面才翻出来看了的...===========
    对DE是固定的..
      

  8.   

    我以前写的这个
    :\s*?(?<area>[\s\S]*?)\s+?(?<type>\b[HA]\b)
    在这也是可以用的,只不过是多了   DE    ,需要再分离一下就可以了,用我上面给的那个吧<td[^>]*?>[^:]*?:(?<area>[\s\S]*?)\s*?DE\s*?(?<type>\b[HA]\b)</td>
      

  9.   

    <tr> 
                    <td width="11" height="22"> </td>
                    <td width="201">002:Dalvengyr    DE       H</td>
                    <td width="82">0.14元/金币</td>
                    <td width="70" align="center">200</td>
                    <td width="70" align="center">1000</td>
                    <td width="42"  align="center"> 正常 </td> <table width="518" border="0" align="center" cellpadding="0" cellspacing="0" class=text>
                  <tr> 
                    <td width="11" height="22"> </td>
                    <td width="201">017:Agamaggan   UK   A</td>
                    <td width="82">0.10元/金币</td>
                    <td width="70" align="center">200</td>
                    <td width="70" align="center">0</td>
                    <td width="42"  align="center">                   <font color="8D3917">满仓</font>  </td>
                    <td width="42" align="center"> 
                      
                      <font color="8D3917">满仓</font> 
                      
                      </font></td>
                  </tr>
                </table>式子:
    <tr>\s+<td[^>]*?>\s+</td>\s+<td[^>]*?>[^:]*?:(?<area>[\S\s]*?)\s+(?<type>[AH])</td>\s+<td[^>]*?>(?<price>0\.\d{1,2})[^<]*?</td>\s+<td[^>]*?>[^<]*?</td>\s+<td[^>]*?>(?<num>[^<]*?)</td>\s+<td[^>]*?>(<font[^>]*?>)?(?<state>)[^<]*?(</font>\s+)?</td>不能匹配,,
    都写累了.眼花
      

  10.   

    <tr>\s+<td[^>]*?>[^<]*?</td>\s+<td[^>]*?>[^:]*?:(?<area>[\S\s]*?)\s+?(?<type>\b[AH]\b)</td>\s+<td[^>]*?>(?<price>0\.\d{1,2})[^<]*?</td>\s+<td[^>]*?>[^<]*?</td>\s+<td[^>]*?>(?<num>[^<]*?)</td>\s+<td[^>]*?>(?<state>)[^<]*?</td>还是不行啊..
      

  11.   

    下面那个怎么两个“满仓”啊,与以前的格式不同了                  <font color="8D3917">满仓</font>  </td>
                    <td width="42" align="center"> 
                      
                      <font color="8D3917">满仓</font> 
                      
                      </font></td>匹配上面的用这个吧<tr>\s+<td[^>]*?>[^<]*?</td>\s+<td[^>]*?>[^:]*?:(?<area>[\S\s]*?)\s+(?<type>[AH])</td>\s+<td[^>]*?>(?<price>0\.\d{1,2})[^<]*?</td>\s+<td[^>]*?>[^<]*?</td>\s+<td[^>]*?>(?<num>[^<]*?)</td>\s+<td[^>]*?>(<font[^>]*?>)?(?<state>)[^<]*?(</font>\s+)?</td>前面那个空格不知是全角还是什么的,\s+匹配起来有问题,还是改成[^<]*?吧
      

  12.   

    地址:
    http://www.pvp-wow.com/pvp/youxi.asp?catid=27
      

  13.   

    lxcnn(过客) ( ) 兄你的QQ啊???
    我的:282944601明天没解决再Q你,哈
      

  14.   

    正则
    <tr>\s+<td[^>]*?>[^<]*?</td>\s+<td[^>]*?>[^:]*?:(?<area>[\s\S]*?)\s*?(\S+)\s*?(?<type>\b[HA]\b)</td>\s+<td[^>]*?>(?<price>0\.\d{1,2})[^<]*?</td>\s+<td[^>]*?>[^<]*?</td>\s+<td[^>]*?>(?<num>[^<]*?)</td>\s+<td[^>]*?>\s*(<font[^>]*?>)?(?<state>[^<]*?)(</font>)?\s*</td>
    我的测试代码
    string yourStr = richTextBox1.Text;
    MatchCollection mc = Regex.Matches(yourStr, @"<tr>\s+<td[^>]*?>[^<]*?</td>\s+<td[^>]*?>[^:]*?:(?<area>[\s\S]*?)\s*?(\S+)\s*?(?<type>\b[HA]\b)</td>\s+<td[^>]*?>(?<price>0\.\d{1,2})[^<]*?</td>\s+<td[^>]*?>[^<]*?</td>\s+<td[^>]*?>(?<num>[^<]*?)</td>\s+<td[^>]*?>\s*(<font[^>]*?>)?(?<state>[^<]*?)(</font>)?\s*</td>", RegexOptions.IgnoreCase);
    foreach (Match m in mc)
    {
        richTextBox2.Text += m.Groups["area"].Value + "\n";
        richTextBox2.Text += m.Groups["type"].Value + "\n";
        richTextBox2.Text += m.Groups["price"].Value + "\n";
        richTextBox2.Text += m.Groups["num"].Value + "\n";
        richTextBox2.Text += m.Groups["state"].Value + "\n\n";
    }不过我看DE、UK等等代表的是国家,那个不取到area里吗,这里没有取到里面
      

  15.   

    上面测试取到446条记录,我是在你写的正则基础上修改的,有些细节没有仔细看,如果换一页,有匹配不了的,用排除法找下错误吧最近比较忙,我QQ几乎不在线,不过CSDN倒是天天上,找我PM就行,不过要用新版短消息,旧版的没有消息提示,如果要我QQ号,短消息告诉你吧