$re = '/(<(span|br)\b[^>]*>).*?(<\/\2>)/';
$str = '<p><span>Discover a new tough case for your iPhone 5 with Active Urban</span><span>™</span><span> Case from Cat phones.<br/>Made to survive the challenges of everyday life, this protective case will shield your device whether you\'ve chucked it in your bag, dropped it on the floor or left it in clumsy hands.<br>No matter the situation, the Active Urban</span><span>™</span><span> Case will live up to the challenge.</span></p>';
preg_match_all($re, $str, $matches);
// Print the entire match result
print_r($matches);
The issue with my regex is that it doesn't match self closing tags like br
and also it selects the entire span
, I just need to strip the tags, not its contents.