Home ›
Strip non-numeric characters from a string with PHP Perl-style regular expressionStrip non-numeric characters from a string with PHP Perl-style regular expression
Submitted by Benjamin Melançon on February 23, 2010 - 6:11am
<?php
$numbers_only_string = preg_replace('/\D/', '', $string);
?>
Yeah, that there's a regexp character for "not a digit". Craziness.
Searched words:
php strip non numeric characters
take numbers out of text
remove extra input from number value
Comments
thanks
great tip
Post new comment