preg_match_all usage problem
Posted: Sun Jan 21, 2007 1:48 pm
I've been going through regex tutorials and just can't get this to work. From what I read, this should work. But, it doesn't. Any help is appreciated.
I'm trying to extract the text between class="green"> and </a>, and put any matches in an array. Later, I will extract just the text inbetween, as that's no problem. Here's what I have, which isn't working:
Thanks for reading.
I'm trying to extract the text between class="green"> and </a>, and put any matches in an array. Later, I will extract just the text inbetween, as that's no problem. Here's what I have, which isn't working:
Code: Select all
$String = '<a href="blablabla" class="green">Text that I want to extract</a>';
$SearchPattern = "/class=\"green2\">.+</";
preg_match_all ( $SearchPattern, $String, $Results );
print_r($Results );
// results in Array ( [0] => Array ( ) )