Re: use preg_replace to nix and line with "display: none"

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, Aug 9, 2009 at 12:17 AM, Rob Gould<gouldimg@xxxxxxx> wrote:
> I wish I could say this works, but I'm not having success with this pattern.
>  All the lines with display: none are still in the $bl string.
>
> On Aug 9, 2009, at 1:50 AM, LinuxManMikeC wrote:
>
> <li id="bullet_ug1_col2_9" style="display: list-item;">Reserved Frontstretch
>
> Tower Ticket to the Camping World 300 on Saturday </li>
>
> <li id="bullet_2_9" style="display: list-item;">Reserved Frontstretch Tower
>
> Ticket to the Daytona 500 on Sunday </li>
>
> <li id="bullet_addon_col2_9" style="display: none;"/>
>
> <li id="bullet_addon3_9" style="display: none;"/>
>
> <li id="bullet_option2_col4_9" style="display: none;"/>
>
> <li id="bullet_option2_col3_9" style="display: none;"/>
>
> <li id="bullet_option2_col2_9" style="display: none;"/>
>
> <li id="bullet_option2_col1_9" style="display: none;"/>
>
> <li id="bullet_option3_col4_9" style="display: none;"/>
>
> <li id="bullet_option3_col3_9" style="display: none;"/>
>
> <li id="bullet_option3_col2_9" style="display: none;"/>
>
> <li id="bullet_option3_col1_9" style="display: none;"/>
>
> <li id="bullet_option4_col4_9" style="display: none;"/>
>
> <li id="bullet_option4_col3_9" style="display: none;"/>
>
> <li id="bullet_option4_col2_9" style="display: none;"/>
>
> <li id="bullet_option4_col1_9" style="display: none;"/>
>
> <li id="bullet_option5_col4_9" style="display: none;"/>
>
> <li id="bullet_option5_col3_9" style="display: none;"/>
>
> <li id="bullet_option5_col2_9" style="display: none;"/>
>
> <li id="bullet_option5_col1_9" style="display: none;"/>
>
> <li id="bullet_5_9">Official Daytona 500 Race Week Program </li>
>
> <li id="bullet_6_9">Benchwarmer Sports Souvenir Ticket Protector and Lanyard
>
> </li>
>
> <li id="bullet_7_9">On Site Benchwarmer Tour Staff </li>
>
> <li id="bullet_8_9">All Taxes and Service Charges</li>
>
>
>
>
> I'm CLOSE, but since the style = "display:[space]none" my preg_replace
>
> doesn't catch it.  Can anyone help me determine the correct preg_replace
>
> pattern to do this?
>
> $bl = $_POST['bulletlist'];
>
> $pattern = '|^.+?display:none.+?$|mi';
>
> $bl = preg_replace($pattern,'',$bl);
>
> --
>
> PHP General Mailing List (http://www.php.net/)
>
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
>
> I found your use of ? rather... creative...  Anyway, just add the
> condition "0 or more whitespace" to your regex.
>
> $pattern = '|^.+display:\w*none.+$|';
> I found your use of ? rather... creative...  Anyway, just add the
> condition "0 or more whitespace" to your regex.
>
> $pattern = '|^.+display:\w*none.+$|';
>
>
>

Sorry... my bad... its \s.  I need some sleep.
$pattern = '|^.+display:\s*none.+$|';

Also, if you're certain you'll only ever have one space there, you can
just say that explicitly.
$pattern = '|^.+display: none.+$|';

But I prefer to leave things open for robustness.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux