|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2012-08-06 11:32 UTC] 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. PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||
Copyright © 2001-2026 The PHP GroupAll rights reserved. |
Last updated: Thu Oct 08 02:00:01 2026 UTC |
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.