I have this code:
$tags = implode("|", array("a", "script", "link", "iframe", "img", "object"));
$attrs = implode("|", array("href", "src", "data"));
$any_tag = "\w+(?:\s*=\s*[\"'][^\"']*[\"'])?";
$replace = array(
"/(<(?:$tags)(?:\s*$any_tag)*\s*(?:$attrs)=[\"'])(?![\"']?(?:data:|#))([^'\"]+)([\"'][^>]*>)/" => function($match) {
return $match[1] . $match[2] . $match[3]; // return same data
}
);
$page = preg_replace_callback_array($replace, $page);
echo $page;
and I'm runing this code against https://duckduckgo.com/d2038.js and $page is empty after executing replace, why? If I've added print_r($match)
; in callback I've got:
Array
(
[0] => <a href='/a'>
[1] => <a href='
[2] => /a
[3] => '>
)
the same happen if I assign the value of replace to another variable. Why the page is empty?
If I runing this in regex101 it match more elements https://regex101.com/r/CPGuKd/1 and it don't clear the output.