Re: [PHP] use preg_replace to nix and line with "display: none"
> > $pattern = '|^.+?display:none.+?$|mi'; [8<] > I found your use of ? rather... creative... Anyway, 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
Re: [PHP] use preg_replace to nix and line with "display: none"
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 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.+$|'; > > > 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
Re: [PHP] use preg_replace to nix and line with "display: none"
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: [PHP] use preg_replace to nix and line with "display: none"
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.+$|';
Re: [PHP] use preg_replace to nix and line with "display: none"
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: [PHP] use preg_replace to nix and line with "display: none"
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 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 > > I found your use of ? rather... creative... Anyway, just add the condition "0 or more whitespace" to your regex. $pattern = '|^.+display:\w*none.+$|'; -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php