ID:               13439
 Updated by:       [EMAIL PROTECTED]
 Reported By:      john at scl dot co dot uk
-Status:           Open
+Status:           Bogus
 Bug Type:         Documentation problem
 Operating System: linux 2.2.19
 PHP Version:      4.2.1
 New Comment:

The regex documentation isn't supposed to be an extensive regular
expression's manual, as they are complex.

The current bahaviour is correct, so this is only a problem with you
regex. (I've confirmed this with the author of the regex Oreily's
book).


Previous Comments:
------------------------------------------------------------------------

[2002-10-27 22:28:17] [EMAIL PROTECTED]

So it goes...  

------------------------------------------------------------------------

[2002-06-08 13:13:22] john at scl dot co dot uk

AFAIK, POSIX re's have no concept of non-greedy quantifiers.
All quantifiers are greedy.  But even supposing that this
were a possibility i.e. the * quntifier is non-greedy, the following
needs explaining:

1)  Why the difference between + and * ?

2)  ereg_replace('.*','b','aa') should produce an _infinite_
string of b's because the minimum match is the empty string
and the global ('g' modified) behavior means that there are
an infinity of minimum matches available.

3) ereg_replace('.*c','b','aac') should produce 'ab' but it
doesn't, it produces just 'b'.  In other words, the addition
of the 'c' following the * quantifier has changed the
behaviour from non-greedy to greedy!

There is no consistent explanation available for this
behaviour.  The behaviour is just plain wrong!

------------------------------------------------------------------------

[2002-06-08 08:32:59] msopacua at idg dot nl

I think this can be documentation issue - or a bug.

Remember that ereg(i)_replace functions are always 'g' modified. So
that would make it the issue, whether * is greedy.
By nature + is greedy (cause otherwise the 'or more' wouldn't make
sence), but if it's considered, that * isn't greedy, than what php does
is perfectly correct as each 'a' matches .*.

It would at least be consistent if they we're both greedy as .*? isn't
supported and you can't turn of the global behavior.

------------------------------------------------------------------------

[2002-06-08 07:50:27] john at scl dot co dot uk

I'm running linux 2.2.19.  I've also tested php 4.0.4pl1
running on linux 2.4.2 and the behaviour is the same.

------------------------------------------------------------------------

[2002-06-07 16:48:57] [EMAIL PROTECTED]

Updated the version..which OS are you running PHP on?


------------------------------------------------------------------------

The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
    http://bugs.php.net/13439

-- 
Edit this bug report at http://bugs.php.net/?id=13439&edit=1

Reply via email to