Just add the slash in the character class and capture in group 1:
preg_match_all('@download.php/([^\s.,"\'/]+)@i', $sText, $aMatches);
The value you're looking after is in $aMatches[1][0]
Question
i am trying to get exact word 846002
from html code by using preg_match_all
php code :
<?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>
output:
download.php/829685/Dark
but i want to output only,
829685
Solution
Just add the slash in the character class and capture in group 1:
preg_match_all('@download.php/([^\s.,"\'/]+)@i', $sText, $aMatches);
The value you're looking after is in $aMatches[1][0]
OTHER TIPS
You need to create a group by ( and )
preg_match_all ( '@download.php/([^/]+)@i', $sText, $aMatches );
print_r ( $aMatches[1][0] );