Reputation: 67
I would like to remove html tags in between two $ signs, example:
<p>this is $ and <em> example of </em> what $ I need help with</p>
I'd like to remove the <em> tags in between $, I came up with the following expression but its not quite there
re = <[^>]*>(?=.*\$)
I tried using look behind to finish the job but couldn't figure it out
Upvotes: 2
Views: 54
Reputation: 66
$str = '<p>this is $ and <em> example of </em> what $ I need help $with</p>';
echo preg_replace_callback(
'~\$.*?\$~',
function($matches) {
return strip_tags($matches[0]);
},
$str);
Upvotes: 1