如何提取表格中的内容?
1. 使用_INetGetSource获取的代码内容如下:<td class="rowdata">Y</td>
<td class="rowdata"><a HREF="./Timeline/timelineview.php?ACTID=282774&tmplttype=CBM"target="_blank">View</a></td>
</tr> <tr class=E2data>
<td class="rowdata">Verizon CDMA</td>
<td class="rowdata"><a HREF="#" onmouseover="this.T_WIDTH=300;this.T_ABOVE=true;this.T_OFFSETX=-50;this.T_OFFSETY=32;this.T_FONTSIZE='16px';return escape(', ');">Falls , SD, US</td>
<td class="rowdata">WCDMA CNMTS</td>
<td class="rowdata">Profins Oliver</td>
<td class="rowdata"><a HREF="#" onmouseover="this.T_WIDTH=300;this.T_ABOVE=true;this.T_OFFSETX=-150;this.T_OFFSETY=32;this.T_FONTSIZE='16px';return escape('LOR: CNM can't be launch.<br> ');">LOR: CNMTS can't be launch.</td>
<td class="rowdata">No</td>
<td class="rowdata">1 hour, 6 minutes</td>
<td class="rowdata">Needed</td>
<td class="rowdata">Y</td>
<td class="rowdata">1836632</td>
<td class="rowdata">Y</td>
<td class="rowdata"><a HREF="./Timeline/timelineview.php?ACTID=282779&tmplttype=CNM"target="_blank">View</a></td>
</tr><br /><table WIDTH="95%" align="center">
2. 判断如果匹配关键字CNMTS,则把<tr></tr>之间的所有不包含html代码的内容提取出来。比如:
Verizon CDMA
Falls , SD, US
WCDMA CNMTS
Profins Oliver
LOR: CNMTS can't be launch.
No
1 hour, 6 minutes
Needed
Y
1836632
Y
View
求高手支招! #include <Array.au3>
Local $Str = _
' <td class="rowdata">Y</td>' & @CRLF & _
' <td class="rowdata"><a HREF="./Timeline/timelineview.php?ACTID=282774&tmplttype=CBM"target="_blank">View</a></td>' & @CRLF & _
' </tr> <tr class=E2data>' & @CRLF & _
' <td class="rowdata">Verizon CDMA</td>' & @CRLF & _
' <td class="rowdata"><a HREF="#" onmouseover="this.T_WIDTH=300;this.T_ABOVE=true;this.T_OFFSETX=-50;this.T_OFFSETY=32;this.T_FONTSIZE=' & "'16px';return escape(', ');" & '">Falls , SD, US</td>' & @CRLF & _
' <td class="rowdata">WCDMA CNMTS</td>' & @CRLF & _
' <td class="rowdata">Profins Oliver</td>' & @CRLF & _
' <td class="rowdata"><a HREF="#" onmouseover="this.T_WIDTH=300;this.T_ABOVE=true;this.T_OFFSETX=-150;this.T_OFFSETY=32;this.T_FONTSIZE=' & "'16px';return escape('LOR: CNM can't be launch.<br> ');" & '">LOR: CNMTS can' & "'t be launch.</td>" & @CRLF & _
' <td class="rowdata">No</td>' & @CRLF & _
' <td class="rowdata">1 hour, 6 minutes</td>' & @CRLF & _
' <td class="rowdata">Needed</td>' & @CRLF & _
' <td class="rowdata">Y</td>' & @CRLF & _
' <td class="rowdata">1836632</td>' & @CRLF & _
' <td class="rowdata">Y</td>' & @CRLF & _
' <td class="rowdata"><a HREF="./Timeline/timelineview.php?ACTID=282779&tmplttype=CNM"target="_blank">View</a></td>' & @CRLF & _
' </tr><br /><table WIDTH="95%" align="center">' & @CRLF
;MsgBox(0, '原字符串', $Str)
Local $Test = StringRegExp($str, '(?si)<tr[^>]+>((?:(?!\/tr>).)*CNMTS(?:(?!\/tr>).)*)</tr>', 1)
If @Error Then Exit MsgBox(48, '', '未包含关键字')
Local $Test1 = StringRegExp($Test, '(?<=>)[^<\v"]+(?=<)', 3)
_ArrayDisplay($Test1, UBound($Test))
A版的正则让人看着头疼 正则神人!!!膜拜! 回复 2# afan
如果关键字是“WCDMA CNMTS”中间带空格的话,应该怎么改呢? CNMTS 直接改成 WCDMA CNMTSLocal $Test = StringRegExp($str, '(?si)<tr[^>]+>((?:(?!\/tr>).)*WCDMA CNMTS(?:(?!\/tr>).)*)</tr>', 1) 回复 2# afan
afan版主,请问 (?si) 是什么意思?是(?i)和(?s)的缩写吗? 回复 7# lixiaolong
是的 回复 3# shano
的确是这样,谜一样的正则! 正则表示不懂,学习了!
页:
[1]