I'm trying to replace all instances of paragraphs containing only a series of the same character with a separator tag.
I've used https://www.phpliveregex.com/ to test the code, copied the code straight from there onto php on my server AND on http://phptester.net/, but it will NOT work.
Sample:
$test = "<p>Sed nec convallis tortor. Aenean ante diam, aliquet eget porta in, cursus a nibh. Suspendisse eu tempus sem, sit amet malesuada arcu. Nunc condimentum a elit eget elementum. Curabitur id erat et dolor mattis luctus id id massa.</p>
<p>XXXXXXX</p>
<p><em>Nulla vel ligula arcu. Vivamus nec nisi sit amet dui vulputate suscipit.</em></p>
<p><em>Suspendisse finibus lectus ut elit molestie, ornare accumsan lacus accumsan.</em></p>
<p><em>Fusce vel blandit dolor, ac imperdiet purus.</em>.</p>";
echo preg_replace("/<p>(.)\1{3,}<\/p>/i", "<hr />", $test);
This will still output the <p>XXXXXXX</p>
line, not the intended <hr />
.
Any ideas? Tips?
`? seems to be the issue here. – Funk Forty Niner Sep 22 '18 at 02:12
(.)\1{3,}<\/p>/i", "\
", $test);` did not work for me. – Joseph_J Sep 22 '18 at 02:20