Doc #60177 [Opn->Bgs]: text is inconsistent

From: Date: Tue, 01 Nov 2011 22:18:04 +0000
Subject: Doc #60177 [Opn->Bgs]: text is inconsistent
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-7373@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=60177&edit=1 ID: 60177 Updated by: salathe@php.net Reported by: jasen at treshna dot com Summary: text is inconsistent -Status: Open +Status: Bogus Type: Documentation Problem Package: Documentation problem Operating System: any PHP Version: 5.3.8 Block user comment: N Private report: N New Comment: The "first valid match" with PCRE is "oneself" since the pattern is, unless told otherwise, greedy in nature. "one" will only be first valid match if the pattern is ungreedy. Previous Comments: ------------------------------------------------------------------------ [2011-10-31 02:48:31] jasen at treshna dot com Description: ------------ --- From manual page: http://www.php.net/reference.pcre.pattern.posix --- the text says pcre stops at the first match. > > 3. Using the pattern one(self)?(selfsufficient)? on the string > oneselfsufficient with PCRE will result in matching oneself, but using POSIX > the result will be the full string oneselfsufficient. Both (sub)strings match > the original string, but POSIX requires that the longest be the result. > The first match is 'one' not 'oneself'. preg_match behaves as described (finding 'oneself') but the text does not explain why or how to predict this behaviour. perhaps the definition of 'first' is unclear? Test script: --------------- preg_match('/one(self)?(selfsufficient)?/','oneselfsufficient',$r); print_r($r); /* behaves as described */ preg_match('/one(self)?(selfsufficient)?/','one',$r); print_r($r); /* one is the first match */ ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=60177&edit=1

« previous php.doc.bugs (#7373) next »