[英]preg_match_all not working php
使用preg_match_all
,我可以通过用\\
转义双引号来使用它,但是我无法弄清楚下面的内容。 我知道您必须转义双引号..但仍然无法使用下面的HTML代码
在$html
我有
$html = 'ofReports_ceptframe")[0].src = "https://www.example.com";';
我想从src中提取URL =
我试过了
preg_match_all("/[0].src \= \"(.*?)\"/is", $html, $matches);
foreach($matches[1] as $url);
echo $url;
但不返回任何东西
[
和]
具有特殊含义,您必须对它们进行转义:
preg_match_all("/\[0\]\.src = \"(.*?)\"/is", $html, $matches);
要一一打印结果:
foreach ($matches[1] as $url) {
echo "$url\n";
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.