note 103985 deleted from function.preg-replace by crell
| From: | crell@php.net | Date: | Fri, 01 Jul 2022 19:46:08 +0000 |
| Subject: | note 103985 deleted from function.preg-replace by crell | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-218852@lists.php.net to get a copy of this message | ||
Note Submitter: craiga at craiga dot id dot au
----
If there's a chance your replacement text contains any strings such as "$0.95",
you'll need to escape those $n backreferences:
<?php
function escape_backreference($x)
{
return preg_replace('/\$(\d)/', '\\\$$1', $x);
}
?>