请问这个正则如何写
请教这个正则怎么写
问题:
想用正则提取数据,格式如下:
unread=true 也买酒 喝好酒 其实不用钱 4月22日
下面是网页部分源码:
<div class="toarea"> <table cellspacing="0" class="i F">
<tr>
<td class="cx"><input totime="1303483638000" type="checkbox" unread=true fn="也买酒" fa="reed_kse@precelt.net" name="mailid" value="ZC1422-twP1XTisuVHgflMeQfNBA14"/></td>
<td class="ci">
<div class="ciz " > </div>
<div class="cir Ru" title=""> </div>
<div class="cij"> </div>
</td>
<td onClick="getTop().RD(event,'ZC1422-twP1XTisuVHgflMeQfNBA14',1,1,1,0,0,'','3638');" class="l">
<table cellspacing="0" class="i bold">
<tr>
<td class="tl tf" title="reed_kse@precelt.net"><nobr>也买酒 </nobr></td>
<td class="fg_n ">
<div></div>
</td>
<td class="gt tf">
<div>
<u tabindex="0" class="black ">喝好酒 其实不用钱</u><b class="no " > - 如不显示看这里 </b>
</div>
<div class="TagDiv">
</div>
</td>
<td class="dt"><div>4月22日 </div></td>
<td class="fg">
<div></div>
------解决方案--------------------
问题:
想用正则提取数据,格式如下:
unread=true 也买酒 喝好酒 其实不用钱 4月22日
下面是网页部分源码:
<div class="toarea"> <table cellspacing="0" class="i F">
<tr>
<td class="cx"><input totime="1303483638000" type="checkbox" unread=true fn="也买酒" fa="reed_kse@precelt.net" name="mailid" value="ZC1422-twP1XTisuVHgflMeQfNBA14"/></td>
<td class="ci">
<div class="ciz " > </div>
<div class="cir Ru" title=""> </div>
<div class="cij"> </div>
</td>
<td onClick="getTop().RD(event,'ZC1422-twP1XTisuVHgflMeQfNBA14',1,1,1,0,0,'','3638');" class="l">
<table cellspacing="0" class="i bold">
<tr>
<td class="tl tf" title="reed_kse@precelt.net"><nobr>也买酒 </nobr></td>
<td class="fg_n ">
<div></div>
</td>
<td class="gt tf">
<div>
<u tabindex="0" class="black ">喝好酒 其实不用钱</u><b class="no " > - 如不显示看这里 </b>
</div>
<div class="TagDiv">
</div>
</td>
<td class="dt"><div>4月22日 </div></td>
<td class="fg">
<div></div>
------解决方案--------------------
- VB code
'此代码由“正则测试工具 v1.1.33”自动生成,请直接调用TestReg过程 Private Sub TestReg() Dim strData As String Dim reg As Object Dim matchs As Object, match As Object strData = "<div class=""toarea""> <table cellspacing=""0"" class=""i F"">" & vbCrLf & _ "<tr>" & vbCrLf & _ "<td class=""cx""><input totime=""1303483638000"" type=""checkbox"" unread=true fn=""也买酒"" fa=""reed_kse@precelt.net"" name=""mailid"" value=""ZC1422-twP1XTisuVHgflMeQfNBA14""/></td>" & vbCrLf & _ "<td class=""ci"">" & vbCrLf & _ "<div class=""ciz "" > </div>" & vbCrLf & _ "<div class=""cir Ru"" title=""""> </div>" & vbCrLf & _ "<div class=""cij""> </div>" & vbCrLf & _ "</td>" & vbCrLf & _ "<td onClick=""getTop().RD(event,'ZC1422-twP1XTisuVHgflMeQfNBA14',1,1,1,0,0,'','3638');"" class=""l"">" & vbCrLf & _ "<table cellspacing=""0"" class=""i bold"">" & vbCrLf & _ "<tr>" & vbCrLf & _ "<td class=""tl tf"" title=""reed_kse@precelt.net""><nobr>也买酒 </nobr></td>" & vbCrLf & _ "<td class=""fg_n "">" & vbCrLf & _ "<div></div>" & vbCrLf & _ "</td>" & vbCrLf & _ "<td class=""gt tf"">" & vbCrLf & _ "<div>" & vbCrLf & _ "<u tabindex=""0"" class=""black "">喝好酒 其实不用钱</u><b class=""no "" > - 如不显示看这里 </b> " & vbCrLf & _ "</div>" & vbCrLf & _ "<div class=""TagDiv"">" Set reg = CreateObject("vbscript.regExp") reg.Global = True reg.IgnoreCase = True reg.MultiLine = True reg.Pattern = "unread=(.+?) fn=""(.+?)""[\S\s]*?class=""black "">(.+?)</u>[\S\s]*?class=""dt""><div>(.+?) " Set matchs = reg.Execute(strData) For Each match In matchs 'Debug.Print match.Value Debug.Print match.SubMatches(0) Next End Sub