I would like to remove all &a>
tags and all &br>
tags after which the href
starts with #title
as shown below.
preg_match_all
is not working well with the current code.
How should I change it?
$content
<p>
<a href="#title1">stack</a>
<br>
<a href="#title2">overflow</a>
<br>
</p>
Current Code
if(preg_match_all('|<a href="#title.*?">(.*?)</a>br>|mis', $content, $matches, PREG_SET_ORDER)){
if(!empty($matches)){
$content=preg_replace('|<a href="#title.*?">(.*?)</a>br>|mis',',',$content);
}
}
I suspect that there is a new line code (\r\n
or \r
or \n
or \n
) between <a>
and , so I'll put the relevant part
</a>(\r\n|\r|\n)<br>
What if?
© 2023 OneMinuteCode. All rights reserved.