#47590 [Opn->Bgs]: Discrepancy between documentation and reality for PCRE

From: Date: Fri, 06 Mar 2009 21:32:00 +0000
Subject: #47590 [Opn->Bgs]: Discrepancy between documentation and reality for PCRE
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-1950@lists.php.net to get a copy of this message
 ID:          47590
 Updated by:  rquadling@php.net
 Reported By: johan at qx dot se
-Status:      Open
+Status:      Bogus
 Bug Type:    Documentation problem
 PHP Version: Irrelevant
 New Comment:

You cannot use an unescaped terminator in your regex. If you don't 
wish to escape it, then use a different terminator.

http://docs.php.net/manual/en/pcre.examples.php
gives examples of 
different terminators.





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

[2009-03-06 17:23:43] johan at qx dot se

Description:
------------
In http://se.php.net/manual/en/regexp.reference.php,
it is stated that
(copy-paste):
"All non-alphanumeric characters other than \, -, ^ (at the start) and
the terminating ] are non-special in character classes, but it does no
harm if they are escaped."

I suggest that you change this to:
"All non-alphanumeric characters other than /, \, -, ^ (at the start)
and the terminating ] are non-special in character classes, but it does
no harm if they are escaped."

However, the '/' (slash) character is still considered a pattern
terminator within a character class.

Reproduce code:
---------------
Code:
preg_match_all('/[^/]*/uU', $str, $match);

Expected result:
----------------
Expected:
preg_match_all to find relevant results


Actual result:
--------------
Actual result:
preg_match_all() [function.preg-match-all]: Unknown modifier ']'


And this is due to the fact that the / in [^/] is considered to
terminate the pattern, and thus the following character ] is considered
to be a pattern modifier.


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


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



Thread (5 messages)

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