
November 21st, 2008, 03:56 PM
|
 |
Sarcky
|
|
Join Date: Oct 2006
Location: Pennsylvania, USA
|
|
Since your HTML is so weirdly formed, I couldn't find a decent way to do this with a pure regexp. Here's a PHP implementation:
PHP Code:
$string = '<span class="descBold">1<span class="null">9999</span>2<span class="null2">8888</span><span class="null3">7777</span><span class="null4">5555</span><span class="notnull">3</span></span>';
preg_match_all("/<span( class=['\"](.+?)['\"])?>([^<]+)/", $string, $foo);
foreach ( $foo[2] AS $key => $className ) {
if ( substr($className, 0, 4) != 'null' ) {
echo $foo[3][$key] . "\n";
}
}
Outputs 1 and 3
-Dan
__________________
HEY! YOU! Read the New User Guide and Forum Rules
"They that can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety." -Benjamin Franklin
"The greatest tragedy of this changing society is that people who never knew what it was like before will simply assume that this is the way things are supposed to be." -2600 Magazine, Fall 2002
Think we're being rude? Maybe you asked a bad question or you're a Help Vampire. Trying to argue intelligently? Please read this.
|