|   | php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login | 
| 
 PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits              [2012-06-27 03:13 UTC] rasmus@php.net
  [2012-06-27 13:16 UTC] felipe@php.net
 
-Status: Open
+Status: Not a bug
  [2012-06-27 13:16 UTC] felipe@php.net
  [2012-06-28 01:26 UTC] danielklein at airpost dot net
 | |||||||||||||||||||||||||||
|  Copyright © 2001-2025 The PHP Group All rights reserved. | Last updated: Fri Oct 31 12:00:01 2025 UTC | 
Description: ------------ The "\k" escape must be followed by 'name', <name> or {name}. A PCRE regex that contains "\k" without the properly quoted name will compile without an error and will always fail as "\k" can never (as far as I know) match anything in the subject string. It is almost identical to "\g", except "\g" also allows "\gn", "\g{n}" or "\g{-n}" where "n" is any positive decimal number. I have been unable to test PCRE directly (i.e. via the command line, not through PHP) as I can't compile it on my computer. I have looked through the source code and the test results, and from that it seems to be working correctly. Although I'm not 100% sure, I think this bug is specific to PHP. Test script: --------------- <?php var_dump(preg_match('/\k/', 'foo')); // Missing named reference var_dump(preg_match('/\g/', 'foo')); // Missing named or numbered reference ?> Expected result: ---------------- Warning: preg_match(): Compilation failed: **something about name missing in \k back-reference** at offset 1 in test.php on line 3 bool(false) Warning: preg_match(): Compilation failed: a numbered reference must not be zero at offset 1 in test.php on line 3 bool(false) Actual result: -------------- int(0) Warning: preg_match(): Compilation failed: a numbered reference must not be zero at offset 1 in test.php on line 3 bool(false)