Re: Sigh....regex - need to search/replace string for anything but numbers
| From: | Rick Fletcher | Date: | Wed, 26 Jan 2005 00:40:00 +0000 |
| Subject: | Re: Sigh....regex - need to search/replace string for anything but numbers | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-207336@lists.php.net to get a copy of this message | ||
Matt Babineau wrote:
Ahh so the regex gods are pissed at me. This is simple (I think), but I need to figure out how to strip out everything in a string that is not a number. Any takers?I appear to have written that last snippet without really even looking at it. This one works. <?php $string = "asd98.a98asd/7987asd"; $numbers = preg_replace( "/[^0-9]/", "", $string ); ?>