Forum Moderators: coopster
Using preg_match_all('/<tag>.*</tag>/') doesn't work. It skips over the first instance of </tag>, and stops at the second.
I've tried using '/<tag>([[:alnum:][:blank:][:punct:]]*)<\/tag>/' but that also doesn't work. Adding the [:punct:] results in the same thing that using .* does--skipping over the first instance of </tag> and stopping at the second. I guess this is because it counts the closing tag </ as punctuation, but then why does it stop at the 2nd instance of the tag?
I'm currently using the code;
$match=array();
$html = 'some html code';
if($num=preg_match_all('/<tag>([a-zA-Z0-9<i><\/i>\s\.\-\',]*)<\/tag>/', $html, $match)){
echo "$num matches were found <br>";
} This works mostly, and does stop at the first instance of </tag>, but it doesn't always capture everything.
Any help would be appreciated :)