help with preg_replace pattern
am 27.01.2010 04:37:52 von Rob Gould
--Boundary_(ID_8xkdkZIo9ky69bKWhh8GGg)
Content-type: text/plain; charset=us-ascii
Content-transfer-encoding: 7BIT
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 =
Reserved Frontstretch Tower Ticket to the NextEra Energy Resources 250 on Friday Night
Reserved Frontstretch Tower Ticket to the Camping World 300 on Saturday
Reserved Frontstretch Tower Ticket to the Daytona 500 on Sunday
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 = '/]*style="display: none[^>]*>/';
$bl = preg_replace($pattern,'',$bl);
$pattern = '/]*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.
--Boundary_(ID_8xkdkZIo9ky69bKWhh8GGg)--
Re: help with preg_replace pattern
am 27.01.2010 05:57:49 von Adam Richardson
--00148530ac637e0422047e1e3e34
Content-Type: text/plain; charset=ISO-8859-1
On Tue, Jan 26, 2010 at 10:37 PM, Rob Gould wrote:
> 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 =
>
>
>
>
>
>
> Reserved Frontstretch
> Tower Ticket to the NextEra Energy Resources 250 on Friday Night
> Reserved Frontstretch
> Tower Ticket to the Camping World 300 on Saturday
> Reserved Frontstretch Tower
> Ticket to the Daytona 500 on Sunday
>
>
>
>
>
>
>
>
>
>
>
>
>
> 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 = '/]*style="display: none[^>]*>/';
> $bl = preg_replace($pattern,'',$bl);
>
> $pattern = '/]*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.
>
>
>
>
>
>
Your regex is looking for case-sensitive matches, which given the example
below, would preclude all of your list items (they all start with "
"
Try using a case insensitive regex (e.g., $bl = preg_replace($pattern
= /]*style="DISPLAY: none[^>]*>/i','',$bl);
(Note the "i" after the search pattern above.)
Adam
--
Nephtali: PHP web framework that functions beautifully
http://nephtaliproject.com
--00148530ac637e0422047e1e3e34--