Php preg_match没有得到任何东西

Php preg_match没有得到任何东西,php,preg-match,Php,Preg Match,我想从代码的某些行中获取一个值,这是我当前的代码: $body = "<td class='tam12'><img src='/assets/img/banderas/es.png' width='30' height='20' /></td><td class='tam12'>2017-05-22</td><td class='tam12'><img src='/assets/img/servidores/strea

我想从代码的某些行中获取一个值,这是我当前的代码:

$body = "<td class='tam12'><img src='/assets/img/banderas/es.png' width='30' height='20' /></td><td class='tam12'>2017-05-22</td><td class='tam12'><img src='/assets/img/servidores/streamplay.jpg' width='80' height='25' style='border-radius:4px;' /></td><td><a class='capitulo2' href='anonim.php?id=4936681&e=' rel='nofollow' target='_blank' alt=''>Ver online</a>";
$patternopenload = "#<img src='/assets/img/banderas/es.png' width='[^']*' height='[^']*' /></td><td class='tam12'>[^']*</td><td class='tam12'><img src='/assets/img/servidores/streamplay.jpg' width='[^']*' height='[^']*' style='[^']* /></td><td><a class='[^']*' href='(.*?)' rel='nofollow' target='_blank' alt=''>Ver online</a></td>";
preg_match($patternopenload, $body, $primero);
echo $primero[1];
$body=“2017-05-22”;
$patternopenload=“#[^']*”;
预匹配($patternopenload,$body,$primero);
echo$primero[1];
但我什么也没得到。我不明白为什么我至少修改了50次,如果有人能帮助我,我将非常感激

您必须使用/in regex模式:

preg_match要求你做类似的事情

preg_match('/{pattern}/', $subject);
假设您想要获取href链接,那么regex应该

$patternopenload = "/<a class='capitulo2' href='(.+)' rel='.+' target='.+'/";

$patternopenload=“/是的,它起作用了,但我必须在模式中包含这两个
,因为我需要它们用于将来的preg\u match\u所有从只有那些img的
中获取href的东西,如果我添加它们,它就不起作用了,因为你想要获取链接和图像url吗?首先,不要用正则表达式解析HTML。您在正则表达式中遗漏了结尾分隔符(即
…Ver online#“;
@Toto是的,我在发送帖子后注意到了它,我修复了它,但它仍然不起作用