note 47015 deleted from function.ereg-replace by kennyt
| From: | kennyt@php.net | Date: | Wed, 26 Jan 2005 03:54:09 +0000 |
| Subject: | note 47015 deleted from function.ereg-replace by kennyt | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-83981@lists.php.net to get a copy of this message | ||
Note Submitter: pacogliss
----
Use of brackets in ereg_replace expressions allows replacement of only part of the pattern you are
looking for.
After crashing over the "this is a test" example, I made out these hopefully
self-explaining chunks of code :
$string1= "......45645.6458";
echo "=>".ereg_replace("([0-9]{1})(\.)","\\1,", $string1);
// =>......45645,6458 : dot preceded by number is replaced by coma
echo "=>".ereg_replace("([0-9]{1})(\.)","P\\2", $string1);
// =>......4564P.6458 : number preceding a dot is replaced by letter "P" (pardon the
kafkaism, for the sake of example ;-)