php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #24571 preg ungreedy modifier documentation unclear
Submitted: 2003-07-09 19:34 UTC Modified: 2004-08-07 17:09 UTC
From: matthewb at syrah dot us Assigned:
Status: Closed Package: Documentation problem
PHP Version: Irrelevant OS: Irrelevant
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: matthewb at syrah dot us
New email:
PHP Version: OS:

 

 [2003-07-09 19:34 UTC] matthewb at syrah dot us
Description:
------------
The preg documentation for setting the ungreedy modifier in the middle of a pattern is unclear on this page:

http://www.php.net/manual/en/pcre.pattern.modifiers.php

In the "U (PCRE_UNGREEDY)" section it says: 

"It [the ungreedy modifier] can also be set by a (?U) modifier setting within the pattern."

This is confusing.  Why is the "U" inside the parentheses?  Why are the parentheses even here?  As far as I can tell, neither the parentheses nor the U have anything to do with using "?" to make a particular quantifier ungreedy within a pattern.  Specifically, neither /,.*?U,/ nor /,.*(?U),/ seem to make the * ungreedy.

In my opinion, it would be more clear to say:

"The ungreedy modifier can also be applied to individual quantifiers within a pattern by placing a "?" after the quantifier. For example /,.*?,/ will ungreedily match characters between the commas."

(Aside: I admit that the effects of the "?" inside patterns is well documented on this page:

http://www.php.net/manual/en/pcre.pattern.syntax.php

But unfortunately the word "ungreedy", while it does appear on the page, does not appear near the section describing the ungreedy effects of "?".)

Many thanks.


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-08-07 17:09 UTC] vrana@php.net
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.

Thank you for the report, and for helping us make our documentation better.

Added entry to regexp.reference.internal-options (syntax) and link there (modifiers).
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Jun 24 11:01:32 2024 UTC