I need to hide all "p" tags in a HTML file that have an inline style with a "left" offset of 400 or more.
I'm hoping some clever regex will replace "left:XXX" with "display:none" should "xxx" be 400 or more.
For example, this:
<p style="position:absolute;top:98px;left:472px;white-space:nowrap">
...would need to be replaced with this:
<p style="position:absolute;top:98px;display:none;white-space:nowrap">
It seems simple enough logic, but the regex and PHP is mind boggling for me.
Here is what I've been trying to do, but I can only get it to work line-by-line:
$width = preg_match("left:(.*?)px",$contents);
if ($width >399)
{
$contents = preg_replace('/left:(.*?)px/', "display:none", $contents);
}
Any suggestions greatly appreciated! :)
Wonko
$re = "/<p\\s+[^<]*style=\"[^\"]*left:\\K(?:[4-9][0-9][0-9]|[1-9][0-9][0-9][0-9])px/i";(to be replaced withdisplay:none). I am not posting, since most probably this question is going to be closed by "xeger"-people.