Re: Sigh....regex - need to search/replace string for anything but numbers
| From: | Jason Barnett | Date: | Wed, 26 Jan 2005 00:21:33 +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-207330@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?<?php $text = 'waf4u8r94$@%$G^#U`][\/.msg2g21vdbb 5g2g25g9 2 02025'; echo preg_replace('/[^0-9]/', '', $text); ?>
Thanks, Matt Babineau Criticalcode w: http://www.criticalcode.com p: 858.733.0160 e: matt@criticalcode.com-- Teach a man to fish... NEW? | http://www.catb.org/~esr/faqs/smart-questions.html STFA | http://marc.theaimsgroup.com/?l=php-general&w=2 STFM | http://www.php.net/manual/en/index.php STFW | http://www.google.com/search?q=php LAZY | http://mycroft.mozdev.org/download.html?name=PHP&submitform=Find+search+plugins