use preg_replace to nix and line with "display: none"
use preg_replace to nix and line with "display: none"
am 09.08.2009 07:14:51 von Rob Gould
I have a bunch of bullets in a list coming from a previous post, and I
need to eliminate any line from this string that contains "display:
none"
Reserved
Frontstretch Tower Ticket to the Camping World 300 on Saturday
Reserved Frontstretch
Tower Ticket to the Daytona 500 on Sunday
Official Daytona 500 Race Week Program
Benchwarmer Sports Souvenir Ticket Protector and
Lanyard
On Site Benchwarmer Tour Staff
All Taxes and Service Charges
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
Re: use preg_replace to nix and line with "display: none"
am 09.08.2009 07:50:04 von LinuxManMikeC
On Sat, Aug 8, 2009 at 11:14 PM, Rob Gould wrote:
> I have a bunch of bullets in a list coming from a previous post, and I ne=
ed
> to eliminate any line from this string that contains "display: none"
>
>
> Reserved Front=
stretch
> Tower Ticket to the Camping World 300 on Saturday
> Reserved Frontstretch=
Tower
> Ticket to the Daytona 500 on Sunday
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> Official Daytona 500 Race Week Program
> Benchwarmer Sports Souvenir Ticket Protector and La=
nyard
>
> On Site Benchwarmer Tour Staff
> All Taxes and Service Charges
>
>
>
>
> I'm CLOSE, but since the style =3D "display:[space]none" my preg_replace
> doesn't catch it. Â Can anyone help me determine the correct preg_rep=
lace
> pattern to do this?
>
> $bl =3D $_POST['bulletlist'];
> $pattern =3D '|^.+?display:none.+?$|mi';
> $bl =3D 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 =3D '|^.+display:\w*none.+$|';
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: use preg_replace to nix and line with "display: none"
am 09.08.2009 07:53:34 von Michael Peters
Rob Gould wrote:
> I have a bunch of bullets in a list coming from a previous post, and I
> need to eliminate any line from this string that contains "display: none"
>
>
>
Reserved
> Frontstretch Tower Ticket to the Camping World 300 on Saturday
> Reserved Frontstretch
> Tower Ticket to the Daytona 500 on Sunday
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> Official Daytona 500 Race Week Program
> Benchwarmer Sports Souvenir Ticket Protector and
> Lanyard
> On Site Benchwarmer Tour Staff
> All Taxes and Service Charges
>
>
>
>
> 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);
>
Easy to do with xml tools if your input is easily manipulated by xml
tools, but try this:
$pattern = '/]*style="display: none[^>]*>/';
not tried myself.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: use preg_replace to nix and line with "display: none"
am 09.08.2009 08:17:56 von Rob Gould
--Boundary_(ID_Daj6EXQfy5ignX7rhGtvDg)
Content-type: text/plain; charset=US-ASCII; format=flowed; delsp=yes
Content-transfer-encoding: 7BIT
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:
>
>>
>>
Reserved
>> Frontstretch
>> Tower Ticket to the Camping World 300 on Saturday
>> Reserved
>> Frontstretch Tower
>> Ticket to the Daytona 500 on Sunday
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>> Official Daytona 500 Race Week Program
>> Benchwarmer Sports Souvenir Ticket Protector
>> and Lanyard
>>
>> On Site Benchwarmer Tour Staff
>> All Taxes and Service Charges
>>
>>
>>
>>
>> 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.+$|';
--Boundary_(ID_Daj6EXQfy5ignX7rhGtvDg)--
Re: use preg_replace to nix and line with "display: none"
am 09.08.2009 08:18:59 von Rob Gould
Yay! That worked. Thanks!
On Aug 9, 2009, at 1:53 AM, Michael A. Peters wrote:
> Rob Gould wrote:
>> I have a bunch of bullets in a list coming from a previous post,
>> and I need to eliminate any line from this string that contains
>> "display: none"
>>
Reserved
>> Frontstretch Tower Ticket to the Camping World 300 on Saturday
>> Reserved
>> Frontstretch Tower Ticket to the Daytona 500 on Sunday
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>> Official Daytona 500 Race Week Program
>> Benchwarmer Sports Souvenir Ticket Protector
>> and Lanyard
>> On Site Benchwarmer Tour Staff
>> All Taxes and Service Charges
>> 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);
>
> Easy to do with xml tools if your input is easily manipulated by xml
> tools, but try this:
>
> $pattern = '/]*style="display: none[^>]*>/';
>
> not tried myself.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: use preg_replace to nix and line with "display: none"
am 09.08.2009 08:37:09 von LinuxManMikeC
On Sun, Aug 9, 2009 at 12:17 AM, Rob Gould wrote:
> I wish I could say this works, but I'm not having success with this patte=
rn.
> Â All the lines with display: none are still in the $bl string.
>
> On Aug 9, 2009, at 1:50 AM, LinuxManMikeC wrote:
>
> Reserved Front=
stretch
>
> Tower Ticket to the Camping World 300 on Saturday
>
> Reserved Frontstretch=
Tower
>
> Ticket to the Daytona 500 on Sunday
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> Official Daytona 500 Race Week Program
>
> Benchwarmer Sports Souvenir Ticket Protector and La=
nyard
>
>
>
> On Site Benchwarmer Tour Staff
>
> All Taxes and Service Charges
>
>
>
>
> I'm CLOSE, but since the style =3D "display:[space]none" my preg_replace
>
> doesn't catch it. Â Can anyone help me determine the correct preg_rep=
lace
>
> pattern to do this?
>
> $bl =3D $_POST['bulletlist'];
>
> $pattern =3D '|^.+?display:none.+?$|mi';
>
> $bl =3D 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 =3D '|^.+display:\w*none.+$|';
> I found your use of ? rather... creative... Â Anyway, just add the
> condition "0 or more whitespace" to your regex.
>
> $pattern =3D '|^.+display:\w*none.+$|';
>
>
>
Sorry... my bad... its \s. I need some sleep.
$pattern =3D '|^.+display:\s*none.+$|';
Also, if you're certain you'll only ever have one space there, you can
just say that explicitly.
$pattern =3D '|^.+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
Re: use preg_replace to nix and line with "display: none"
am 10.08.2009 01:39:17 von Ben Dunlap
> > $pattern =3D '|^.+?display:none.+?$|mi';
[8<]
> I found your use of ? rather... creative... =A0Anyway, just add the
You mean the non-greedy flag? I think that's necessary the way the
regex was originally formulated -- without it, ".+display" would
gobble up all of the list-items until the last one.
Ben
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php