来自html的php预匹配
嗨,我需要从网页中提取数据,在这种情况下,我需要从$sting中提取数字278来自html的php预匹配,php,preg-match,Php,Preg Match,嗨,我需要从网页中提取数据,在这种情况下,我需要从$sting中提取数字278 $string = 'title="Metal:| <table class="resourceTooltip"> <tr> <th>Disponible:</th> <
$string = 'title="Metal:| <table class="resourceTooltip">
<tr>
<th>Disponible:</th>
<td><span class="">278<';
$regex ='~title="Metal:| <table class="resourceTooltip">
<tr>
<th>Disponible:</th>
<td><span class="">\s*\((.*?)\)\s*<~';
preg_match($regex , $postResult, $match);
print_r($match);
以上代码输出:
Array ( [0] => title="Metal: )
理想情况下,我不想使用url_解码功能。
希望有人能给我指出正确的方向。试试更简单的方法:
$regex = "/Disponible:\D+(\d+)/";
preg_match($regex,$string,$match);
var_dump($match[1]);
正则表达式的力量来自它们的灵活性。是正则表达式中的一个特殊字符。。。