我正在尝试使用846002
preg_match_all
php代码:
<?php
$sText =file_get_contents('test.html', true);
preg_match_all('@download.php/.[^\s.,"\']+@i', $sText, $aMatches);
print_r($aMatches[0][0]);
?>
的test.html
<tr>
<td class=ac>
<a href="/download.php/846002/Dark.zip"><img src="/dl3.png" alt="Download" title="Download"></a>
</td>
</tr>
输出:
download.php/829685/Dark
但我只想输出,
829685
答案 0 :(得分:0)
只需在字符类中添加斜杠并在第1组中捕获:
preg_match_all('@download.php/([^\s.,"\'/]+)@i', $sText, $aMatches);
您所关注的价值在$aMatches[1][0]
答案 1 :(得分:0)
您需要按(和)
创建一个组preg_match_all ( '@download.php/([^/]+)@i', $sText, $aMatches );
print_r ( $aMatches[1][0] );