note 4088 deleted from preg_replace by torben
| From: | torben@php.net | Date: | Wed, 13 Sep 2000 22:43:34 +0000 |
| Subject: | note 4088 deleted from preg_replace by torben | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-4864@lists.php.net to get a copy of this message | ||
On redhat 6.1 the following happened
<br>
$mystr="454 443 3343";<br>
$str = preg_replace("/[^0-9]/", "//", $mystr);<br>
<br>
One would expect to get all non-numeric values stripped and be left with just the numeric values.
This is not the case however, what you get is<br>
$str = "454//443//3343".<br>
To strip the non-numeric, you leave the replacement string without the /'s...ie <br>
$str=preg_replace("/[^0-9]/", "", $mystr);