note 30748 added to function.preg-replace

From: Date: Thu, 27 Mar 2003 13:41:53 +0000
Subject: note 30748 added to function.preg-replace
Groups: php.notes 
Request: Send a blank email to php-notes+get-45901@lists.php.net to get a copy of this message
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 */ ?> -- http://www.php.net/manual/en/function.preg-replace.php http://master.php.net/manage/user-notes.php?action=edit+30748 http://master.php.net/manage/user-notes.php?action=delete+30748 http://master.php.net/manage/user-notes.php?action=reject+30748

« previous php.notes (#45901) next »