Re: [PHP] Re: strip comments from HTML?

2004-05-07 Thread Rob Ellis
On Thu, May 06, 2004 at 11:48:36PM -0400, Paul Chvostek wrote: > On Thu, May 06, 2004 at 07:11:55PM +, Curt Zirzow wrote: > > > > > > $text="one ", "",$text); > > > > Because your missing a - > > $text="one two\n"; > > /me applies mallet to head > > % php -r '$text="one two\n"; print >

Re: [PHP] Re: strip comments from HTML?

2004-05-06 Thread Paul Chvostek
On Thu, May 06, 2004 at 07:11:55PM +, Curt Zirzow wrote: > > > > $text="one ", "",$text); > > Because your missing a - > $text="one two\n"; /me applies mallet to head % php -r '$text="one two\n"; print ereg_replace("", "",$text);' one two whee, it works! :) -- Paul Chvostek

Re: [PHP] Re: strip comments from HTML?

2004-05-06 Thread John W. Holmes
Justin French wrote: $text = preg_replace('//su','',$text); Did not work (was too greedy, matched multiple comments) Just for the record, it should be a capital 'U' for ungreedy. Lowercase 'u' is something else. :) -- ---John Holmes... Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E

Re: [PHP] Re: strip comments from HTML?

2004-05-06 Thread Justin French
Thanks to everyone who's replied... appears to be quite a tricky one!! $text = preg_replace('//su','',$text); Did not work (was too greedy, matched multiple comments) $text = preg_replace('//','',$text); Did not work (needed multiple lines) $text = preg_replace('//su','',$text);

Re: [PHP] Re: strip comments from HTML?

2004-05-06 Thread David T-G
Michael, et al -- ...and then Michael Sims said... % % David T-G wrote: % > % > Am I missing something painfully obvious? % % www.perldoc.com appears to be unavailable at the moment, but if you have "perldoc" % installed, here's an excerpt from the "perlre" man page: I do, but I looked in the p

Re: [PHP] Re: strip comments from HTML?

2004-05-06 Thread David T-G
Petr, et al -- ...and then Petr U. said... % % On Thu, 6 May 2004 11:57:45 -0400 % David T-G <[EMAIL PROTECTED]> wrote: % % > Am I missing something painfully obvious? % % >From http://www.php.net/manual/en/pcre.pattern.syntax.php % % However, if a quantifier is followed by a question mark,

Re: [PHP] Re: strip comments from HTML?

2004-05-06 Thread Curt Zirzow
* Thus wrote Paul Chvostek ([EMAIL PROTECTED]): > On Thu, May 06, 2004 at 11:26:34AM -0400, Rob Ellis wrote: > > > > > > $text = ereg_replace("","",$text); > > > > you can make the .* less greedy... > > > > $text = preg_replace('//', '', $text); > > Interestingly, from a shell: > > $

Re: [PHP] Re: strip comments from HTML?

2004-05-06 Thread Rob Ellis
On Thu, May 06, 2004 at 12:47:10PM -0400, Paul Chvostek wrote: > On Thu, May 06, 2004 at 11:26:34AM -0400, Rob Ellis wrote: > > > > > > $text = ereg_replace("","",$text); > > > > you can make the .* less greedy... > > > > $text = preg_replace('//', '', $text); > > Interesting to know.

Re: [PHP] Re: strip comments from HTML?

2004-05-06 Thread Paul Chvostek
On Thu, May 06, 2004 at 11:26:34AM -0400, Rob Ellis wrote: > > > > $text = ereg_replace("","",$text); > > you can make the .* less greedy... > > $text = preg_replace('//', '', $text); Interesting to know. My preg-foo is limited; I came at PHP from a background of awk and sed, so when I

Re: [PHP] Re: strip comments from HTML?

2004-05-06 Thread Petr U.
On Thu, 6 May 2004 11:57:45 -0400 David T-G <[EMAIL PROTECTED]> wrote: > > Am I missing something painfully obvious? >From http://www.php.net/manual/en/pcre.pattern.syntax.php However, if a quantifier is followed by a question mark, then it ceases to be greedy, and instead matches the minimu

RE: [PHP] Re: strip comments from HTML?

2004-05-06 Thread Michael Sims
David T-G wrote: > % you can make the .* less greedy... > % > % $text = preg_replace('//', '', $text); > > How does that make it ungreedy? The only thing I see relating > question marks and greediness is that a question mark makes part of a > regexp with a /U modifier (otherwise not greedy) back

Re: [PHP] Re: strip comments from HTML?

2004-05-06 Thread David T-G
Rob, et al -- ...and then Rob Ellis said... % ... % you can make the .* less greedy... % % $text = preg_replace('//', '', $text); How does that make it ungreedy? The only thing I see relating question marks and greediness is that a question mark makes part of a regexp with a /U modifier (oth

Re: [PHP] Re: strip comments from HTML?

2004-05-06 Thread John W. Holmes
From: "Rob Ellis" <[EMAIL PROTECTED]> > you can make the .* less greedy... > > $text = preg_replace('//', '', $text); You still need an 's' modifier if you want to match multi-line comments. The dot character won't match newlines unless you use an 's' modifier. ---John Holmes... -- PHP Genera

Re: [PHP] Re: strip comments from HTML?

2004-05-06 Thread Rob Ellis
On Thu, May 06, 2004 at 11:10:17AM -0400, Paul Chvostek wrote: > On Thu, May 06, 2004 at 03:02:16PM +1000, Justin French wrote: > > > > This isn't working: > > $text = preg_replace('//','',$text); > > > > Can someone advise what characters I need to escape, or whatever to get > > it going? > >

[PHP] Re: strip comments from HTML?

2004-05-06 Thread Paul Chvostek
On Thu, May 06, 2004 at 03:02:16PM +1000, Justin French wrote: > > This isn't working: > $text = preg_replace('//','',$text); > > Can someone advise what characters I need to escape, or whatever to get > it going? It's not a matter of escaping. You're matching too much with the ".*". If you'r