首页新闻找找看学习计划

求一正则表达式

0
悬赏园豆:20 [已解决问题] 解决于 2012-12-03 15:03
<div class="sw2"><div class='swz'>552401</div><div class="swa">[<a href="http://all.qidian.com/book/bookstore.aspx?ChannelId=7" class="hui2">游戏</a>/<a href="http://all.qidian.com/book/bookstore.aspx?ChannelId=7&SubCategoryId=70"   class="hui2">虚拟网游</a>]</div><div class="swb"><span class="swbt"><a href="/Book/10027.aspx" target="_blank">网络贱圣</a> </span><a href="/BookReader/10027,626679.aspx" target="_blank" class="hui2">第一部 贱圣开始了 第十二章 小心!贱招</a>  </div>       <div class="swc">92835</div><div class="swd"><a href="http://me.qidian.com/authorIndex.aspx?id=3091" target="_blank" class="black">地狱爱琴海</a></div>            <div class="swe">05-03-17 11:07</div>        </div><div class="sw1"><div class='swz'>552402</div><div class="swa">[<a href="http://all.qidian.com/book/bookstore.aspx?ChannelId=21" class="hui2">玄幻</a>/<a href="http://all.qidian.com/book/bookstore.aspx?ChannelId=21&SubCategoryId=8"   class="hui2">东方玄幻</a>]</div><div class="swb"><span class="swbt"><a href="/Book/24202.aspx" target="_blank">追寻古武术之路</a> </span><a href="/BookReader/24202,626650.aspx" target="_blank" class="hui2">第十七章 血莲</a>  </div>       <div class="swc">49338</div><div class="swd"><a href="http://me.qidian.com/authorIndex.aspx?id=15043" target="_blank" class="black">轮回的束缚</a></div>            <div class="swe">05-03-22 15:31</div>        </div><div class="sw2"><div class='swz'>552403</div><div class="swa">[<a href="http://all.qidian.com/book/bookstore.aspx?ChannelId=4" class="hui2">都市</a>/<a href="http://all.qidian.com/book/bookstore.aspx?ChannelId=4&SubCategoryId=12"   class="hui2">都市生活</a>]</div><div class="swb"><span class="swbt"><a href="/Book/15695.aspx" target="_blank">好梦</a> </span><a href="/BookReader/15695,626579.aspx" target="_blank" class="hui2">第一章 秦陵之险</a>  </div>       <div class="swc">2943</div><div class="swd"><a href="http://me.qidian.com/authorIndex.aspx?id=9558" target="_blank" class="black">无情的忏悔</a></div>            <div class="swe">05-03-17 09:25</div>        </div>

是这样的一段HTML代码。下面这样看到的清楚一点。

<div class="sw2">
    <div class='swz'>552401</div>
    <div class="swa">[<a href="http://all.qidian.com/book/bookstore.aspx?ChannelId=7" class="hui2">游戏</a>/<a href="http://all.qidian.com/book/bookstore.aspx?ChannelId=7&SubCategoryId=70"   class="hui2">虚拟网游</a>]</div>
    <div class="swb"><span class="swbt"><a href="/Book/10027.aspx" target="_blank">网络贱圣</a> </span><a href="/BookReader/10027,626679.aspx" target="_blank" class="hui2">第一部 贱圣开始了 第十二章 小心!贱招</a>  </div>       
    <div class="swc">92835</div>
    <div class="swd"><a href="http://me.qidian.com/authorIndex.aspx?id=3091" target="_blank" class="black">地狱爱琴海</a></div>            
    <div class="swe">05-03-17 11:07</div>        
</div>
<div class="sw1">
    <div class='swz'>552402</div>
    <div class="swa">[<a href="http://all.qidian.com/book/bookstore.aspx?ChannelId=21" class="hui2">玄幻</a>/<a href="http://all.qidian.com/book/bookstore.aspx?ChannelId=21&SubCategoryId=8"   class="hui2">东方玄幻</a>]</div>
    <div class="swb"><span class="swbt"><a href="/Book/24202.aspx" target="_blank">追寻古武术之路</a> </span><a href="/BookReader/24202,626650.aspx" target="_blank" class="hui2">第十七章 血莲</a>  </div>       
    <div class="swc">49338</div>
    <div class="swd"><a href="http://me.qidian.com/authorIndex.aspx?id=15043" target="_blank" class="black">轮回的束缚</a></div>            
    <div class="swe">05-03-22 15:31</div>        
</div>
<div class="sw2">
    <div class='swz'>552403</div>
    <div class="swa">[<a href="http://all.qidian.com/book/bookstore.aspx?ChannelId=4" class="hui2">都市</a>/<a href="http://all.qidian.com/book/bookstore.aspx?ChannelId=4&SubCategoryId=12"   class="hui2">都市生活</a>]</div>
    <div class="swb"><span class="swbt"><a href="/Book/15695.aspx" target="_blank">好梦</a> </span><a href="/BookReader/15695,626579.aspx" target="_blank" class="hui2">第一章 秦陵之险</a>  </div>       
    <div class="swc">2943</div><div class="swd"><a href="http://me.qidian.com/authorIndex.aspx?id=9558" target="_blank" class="black">无情的忏悔</a></div>            
    <div class="swe">05-03-17 09:25</div>        
</div>


希望抓出来的数据时这样的

sw sw1=new sw();

sw1.a=552401;

sw1.b=“[<a href="http://all.qidian.com/book/bookstore.aspx?ChannelId=7" class="hui2">游戏</a>/<a href="http://all.qidian.com/book/bookstore.aspx?ChannelId=7&SubCategoryId=70"   class="hui2">虚拟网游</a>]”;

sw1.c=92835;

sw1.d="<a href="http://me.qidian.com/authorIndex.aspx?id=3091" target="_blank" class="black">地狱爱琴海</a>";

sw1.e="05-03-17 11:07";

 

sw sw2=new sw();

.......

豆腐欣欣的主页 豆腐欣欣 | 初学一级 | 园豆:76
提问于:2012-12-03 10:45
< >
分享
最佳答案
0
<div\sclass="sw(?:1|2)">\s*<div class='swz'>(\d+)<\/div>\s*<div class="swa">(.*?)<\/div>\s*<div class="swb">(.*?)<\/div>\s*<div\sclass="swc">(\d+)<\/div>\s*<div\sclass="swd">(.*?)<\/div>\s*<div\sclass="swe">(.*?)<\/div>\s*<\/div>

自己去 6 个组里面取吧 !
收获园豆:20
张坤 | 小虾三级 |园豆:1865 | 2012-12-03 15:00

大神哇!!

豆腐欣欣 | 园豆:76 (初学一级) | 2012-12-03 15:03

@跳舞: 好吧,,,,

张坤 | 园豆:1865 (小虾三级) | 2012-12-03 15:08
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册