help with preg_replace pattern
| From: | Rob Gould | Date: | Wed, 27 Jan 2010 03:37:52 +0000 |
| Subject: | help with preg_replace pattern | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-301523@lists.php.net to get a copy of this message | ||
It appears that IE renders it's display: none in all caps while Firefox and other browsers pass
it back in lowercase. This throws off my php line of code the is supposed to nuke blank bullets
from a string of text:
$bl =
<LI style="DISPLAY: none" id=bullet_ug2_col5_8></LI>
<LI style="DISPLAY: none" id=bullet_ug2_col4_8></LI>
<LI style="DISPLAY: none" id=bullet_ug2_col3_8></LI>
<LI style="DISPLAY: none" id=bullet_ug2_col2_8></LI>
<LI style="DISPLAY: none" id=bullet_ug2_8></LI>
<LI style="DISPLAY: none" id=bullet_ug1_col4_8></LI>
<LI style="DISPLAY: list-item" id=bullet_ug1_col3_8>Reserved Frontstretch Tower
Ticket to the NextEra Energy Resources 250 on Friday Night </LI>
<LI style="DISPLAY: list-item" id=bullet_ug1_col2_8>Reserved Frontstretch Tower
Ticket to the Camping World 300 on Saturday </LI>
<LI style="DISPLAY: list-item" id=bullet_2_8>Reserved Frontstretch Tower Ticket to
the Daytona 500 on Sunday </LI>
<LI style="DISPLAY: none" id=bullet_addon_col2_8></LI>
<LI style="DISPLAY: none" id=bullet_addon3_8></LI>
<LI style="DISPLAY: none" id=bullet_option2_col4_8></LI>
<LI style="DISPLAY: none" id=bullet_option2_col3_8></LI>
<LI style="DISPLAY: none" id=bullet_option2_col2_8></LI>
<LI style="DISPLAY: none" id=bullet_option2_col1_8></LI>
<LI style="DISPLAY: none" id=bullet_option3_col4_8></LI>
<LI style="DISPLAY: none" id=bullet_option3_col3_8></LI>
<LI style="DISPLAY: none" id=bullet_option3_col2_8></LI>
<LI style="DISPLAY: none" id=bullet_option3_col1_8></LI>
<LI style="DISPLAY: none" id=bullet_option4_col4_8></LI>
<LI style="DISPLAY: none" id=bullet_option4_col3_8></LI>
I want to keep the "DISPLAY: list-item" lines, and nuke all the others.
The below above are sent to PHP in a variable called $bl. I then try to nuke the "DISPLAY:
none" lines with something like:
$pattern = '/<li[^>]*style="display: none[^>]*>/';
$bl = preg_replace($pattern,'',$bl);
$pattern = '/<li[^>]*style="DISPLAY: none[^>]*>/';
$bl = preg_replace($pattern,'',$bl);
But it appears that the case-sensitivity fix is not just a matter of making the letter capitals.
I'm sure someone who knows more than I about preg_replace will see the
immediate error of my ways. Any advice is greatly appreciated.