I have a string that's throwing up a couple php errors.
I'm using some regex to strip <p>
tags from images and iframes.
I'm also using regex to replace a <br\>
with two <br\><br\>
.
I'm using it on $content
in wordpress.
It's throwing an error and therefore nothing is being returned in the_content();
If I remove the functions the content appears fine, though without the formatting changes.
I assume if I fix these errors the content will work fine but I don't know how to adjust the regex.
Anyway here are the errors:
[12-Aug-2014 19:46:46 UTC] PHP Warning: preg_replace(): Unknown modifier '>' in /functions.php on line 101
[12-Aug-2014 19:46:46 UTC] PHP Warning: preg_replace(): Unknown modifier 'f' in /functions.php on line 102
[12-Aug-2014 19:46:46 UTC] PHP Warning: preg_replace(): Unknown modifier '?' in /functions.php on line 133
And of course the code:
function filter_ptags($content){
$content = preg_replace('/<p>s*(<a .*>)?s*(<img .* />)s*(</a>)?s*</p>/iU', '123', $content);
return preg_replace('/<p>s*(<iframe .*>*.</iframe>)s*</p>/iU', '1', $content);
}
function strip_content($content){
$content = preg_replace(array('/(<brs*/?>s*){1,}/'), array('<br/><br/>'), $content);
}
I really need to spend some time getting a grasp on regex...
\s*()?\s*(
)\s*(<\/a>)?\s*<\/p>` for first one and `
– Braj Aug 12 '14 at 20:12\s*(