Doc #62756 [Csd]: preg documentation should mention '=' should not be first in character class
| From: | marco at greenlightsolutions dot nl | Date: | Wed, 23 Oct 2013 12:53:11 +0000 |
| Subject: | Doc #62756 [Csd]: preg documentation should mention '=' should not be first in character class | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-10535@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=62756&edit=1
ID: 62756
User updated by: marco at greenlightsolutions dot nl
Reported by: marco at greenlightsolutions dot nl
Summary: preg documentation should mention '=' should not be
first in character class
Status: Closed
Type: Documentation Problem
Package: Documentation problem
PHP Version: Irrelevant
Assigned To: daverandom
Block user comment: N
Private report: N
New Comment:
The amended documentation is slightly inaccurate.
The documentation states
"Supplying an expression with a character class that both starts and ends with
<literal>:</literal>, <literal>.</literal> or
<literal>:</literal> characters to PCRE is interpreted as an attempt to use one of these
unsupported features and causes a compilation error."
Unfortunately, the compilation error is also triggered when "supplying an expression with a
character class that start with a <literal>:</literal>, <literal>.</literal>
or <literal>:</literal> character, followed by a different character class that ends
with that same literal".
Also, I strongly urge you to formulate the text in such a way that it includes the phrase
"POSIX collating elements", so that the page will be a top search result when searching
for the error message "Compilation failed: POSIX collating elements are not supported".
Previous Comments:
------------------------------------------------------------------------
[2013-10-23 08:41:57] daverandom@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.
Documented at http://php.net/reference.pcre.pattern.posix
------------------------------------------------------------------------
[2013-10-23 08:40:48] daverandom@php.net
Automatic comment from SVN on behalf of daverandom
Revision: http://svn.php.net/viewvc/?view=revision&revision=331924
Log: Document difference between PCRE and POSIX character classes. Fixes bug #62756.
------------------------------------------------------------------------
[2012-08-06 12:58:51] marco at greenlightsolutions dot nl
You are right.
It actually was part of a compound expression, and I'd overlooked that the other parts were
also relevant. The following line generates the error message:
$x=preg_match("%[=~]|<[>=]%", "test");
(PHP 5.3.8, PCRE 8.13.2011-08-16).
Regardless, the documentation does not mention the '[=..=]' POSIX collating-element
construct. It does not mention the '=' symbol at all. This should be fixed in the
documentation. Ideally, the documentation should also contain the phrase 'POSIX collating
element', so that it appears as a search result when people search for the text of the error
message.
------------------------------------------------------------------------
[2012-08-06 12:32:59] salathe@php.net
[=~] should not be causing the warning, however [=abc=] and [.abc.] will.
------------------------------------------------------------------------
[2012-08-06 11:32:58] marco at greenlightsolutions dot nl
Description:
------------
---
From manual page: http://www.php.net/regexp.reference.character-classes
---
Briefly: The documentation for character classes should state that '=' after '['
is a reserved construct and should be avoided.
In detail:
If you put a '=' first in a character class in a perl regular expression, such as
'[=~]', in certain versions of PHP (including PHP 5.3.8) this will fail to compile, with a
warning "Compilation failed: POSIX collating elements are not supported". Rewriting it as
'[~=]' prevents the error message.
This is because the combination "[=" is seen as indicative of a "POSIX collating
element", a reserved, not-yet-implemented syntactical construct. A full description of the
cause was written up by Tom Christiansen at http://stackoverflow.com/questions/7173787/compilation-failed-posix-collating-elements-are-not-supported#7175589.
The 'preg character classes' documentation page should include the information that
'=' in the beginning of a character class is treated special, but it doesn't mention
the '=' sign at all.
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=62756&edit=1