note 30748 deleted from function.preg-replace by sniper
| From: | sniper@php.net | Date: | Tue, 30 Sep 2003 12:32:45 +0000 |
| Subject: | note 30748 deleted from function.preg-replace by sniper | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-57481@lists.php.net to get a copy of this message | ||
Note Submitter: dino@netcom.inf.br
----
I have a alternative in the case o example 1:
<?php
$str = "April 15, 2003";
$pattern = "/(\w+) (\d+), (\d+)/i";
$replacement = "\${1}1,\$3";
print preg_replace($pattern, $replacement, $string);
/* Output
======
April1,2003
*/
?>
You can use a "0" to complete, like this
<?php
$str = "April 15, 2003";
$pattern = "/(\w+) (\d+), (\d+)/i";
$replacement = "\$011,\$3"; #HERE
print preg_replace($pattern, $replacement, $string);
/* Output
======
April1,2003
*/
?>