Doc #62360 [NEW]: Five valid PCRE escape sequences not documented

From: Date: Tue, 19 Jun 2012 01:28:10 +0000
Subject: Doc #62360 [NEW]: Five valid PCRE escape sequences not documented
Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-8480@lists.php.net to get a copy of this message
From:             danielklein at airpost dot net
Operating system: 
PHP version:      Irrelevant
Package:          Documentation problem
Bug Type:         Documentation Problem
Bug description:Five valid PCRE escape sequences not documented

Description:
------------
---
From manual page: http://www.php.net/regexp.reference.escape
---
There are currently five valid PCRE escape sequences not documented on this
page: \C, \R, \X, \g & \k. Some of these are documented on other pages.

\g & \k - regexp.reference.back-references
\C - regexp.reference.dot
\R matches line break characters or combinations (see
http://nikic.github.com/2011/12/10/PCRE-and-newlines.html)
\X matches Unicode graphemes (see
http://www.regular-expressions.info/unicode.html)

Also, the description for \G is misleading. \G can also match in
preg_match_all or preg_replace at the point where the previous match
stopped (see example script).

Test script:
---------------
preg_match_all('/\b([^\Wv]+)\s+/X', "In the beginning the universe was
created", $matches, PREG_PATTERN_ORDER, 1); // Matches four words not
containing 'v', then followed by a space
var_export($matches[1]);
print("\n");
preg_match_all('/\G\b([^\Wv]+)\s+/X', "In the beginning the universe was
created", $matches, PREG_PATTERN_ORDER, 1); // No matches
var_export($matches[1]);
print("\n");
preg_match_all('/\G\b([^\Wv]+)\s+/X', "In the beginning the universe was
created", $matches, PREG_PATTERN_ORDER, 3); // Able to match \b at offset
3, then two others. No word can have 'v' in it. \G prevents skipping to
next word
var_export($matches[1]);


Actual result:
--------------
array (
  0 => 'the',
  1 => 'beginning',
  2 => 'the',
  3 => 'was',
)
array (
)
array (
  0 => 'the',
  1 => 'beginning',
  2 => 'the',
)

-- 
Edit bug report at https://bugs.php.net/bug.php?id=62360&edit=1
-- 
Try a snapshot (PHP 5.4):            https://bugs.php.net/fix.php?id=62360&r=trysnapshot54
Try a snapshot (PHP 5.3):            https://bugs.php.net/fix.php?id=62360&r=trysnapshot53
Try a snapshot (trunk):              https://bugs.php.net/fix.php?id=62360&r=trysnapshottrunk
Fixed in SVN:                        https://bugs.php.net/fix.php?id=62360&r=fixed
Fixed in SVN and need be documented: https://bugs.php.net/fix.php?id=62360&r=needdocs
Fixed in release:                    https://bugs.php.net/fix.php?id=62360&r=alreadyfixed
Need backtrace:                      https://bugs.php.net/fix.php?id=62360&r=needtrace
Need Reproduce Script:               https://bugs.php.net/fix.php?id=62360&r=needscript
Try newer version:                   https://bugs.php.net/fix.php?id=62360&r=oldversion
Not developer issue:                 https://bugs.php.net/fix.php?id=62360&r=support
Expected behavior:                   https://bugs.php.net/fix.php?id=62360&r=notwrong
Not enough info:                     https://bugs.php.net/fix.php?id=62360&r=notenoughinfo
Submitted twice:                     https://bugs.php.net/fix.php?id=62360&r=submittedtwice
register_globals:                    https://bugs.php.net/fix.php?id=62360&r=globals
PHP 4 support discontinued:          https://bugs.php.net/fix.php?id=62360&r=php4
Daylight Savings:                    https://bugs.php.net/fix.php?id=62360&r=dst
IIS Stability:                       https://bugs.php.net/fix.php?id=62360&r=isapi
Install GNU Sed:                     https://bugs.php.net/fix.php?id=62360&r=gnused
Floating point limitations:          https://bugs.php.net/fix.php?id=62360&r=float
No Zend Extensions:                  https://bugs.php.net/fix.php?id=62360&r=nozend
MySQL Configuration Error:           https://bugs.php.net/fix.php?id=62360&r=mysqlcfg



Thread (7 messages)

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