Doc #72341 [NEW]: Inconsitent $ escaping in preg_replace replacement patterns.

From: Date: Mon, 06 Jun 2016 08:54:31 +0000
Subject: Doc #72341 [NEW]: Inconsitent $ escaping in preg_replace replacement patterns.
Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-13487@lists.php.net to get a copy of this message
From: mark at barrenfrozenwasteland dot com Operating system: N/A PHP version: Irrelevant Package: Documentation problem Bug Type: Documentation Problem Bug description:Inconsitent $ escaping in preg_replace replacement patterns. Description: ------------ --- From manual page: http://www.php.net/function.preg-replace --- "When working with a replacement pattern where a backreference is immediately followed by another number (i.e.: placing a literal number immediately after a matched pattern), you cannot use the familiar \\1 notation for your backreference. \\11, for example, would confuse preg_replace() since it does not know whether you want the \\1 backreference followed by a literal 1, or the \\11 backreference followed by nothing. In this case the solution is to use \${1}1. This creates an isolated $1 backreference, leaving the 1 as a literal." The second-last sentence is confusing since this appears to contradict 2 other parts of the page: the paragraph above which says "replacement may contain references of the form \\n or (since PHP 4.0.4) $n" (no \$), and Example #1 which uses single-quoted string so doesn't require \$. It would be less confusing if all parts of the page used the same style when describing $-delimited backreferences. #47797 also suggested drawing more attention to the escaping requirements, which could be helpful. -- Edit bug report at https://bugs.php.net/bug.php?id=72341&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=72341&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=72341&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=72341&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=72341&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=72341&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=72341&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=72341&r=needscript Try newer version: https://bugs.php.net/fix.php?id=72341&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=72341&r=support Expected behavior: https://bugs.php.net/fix.php?id=72341&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=72341&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=72341&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=72341&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=72341&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=72341&r=dst IIS Stability: https://bugs.php.net/fix.php?id=72341&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=72341&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=72341&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=72341&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=72341&r=mysqlcfg

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