I have a string that contains unwanted numbers ( any number higher than 5000 )
I want a php function to remove any number higher than 5000.
thnx :)
I have a string that contains unwanted numbers ( any number higher than 5000 )
I want a php function to remove any number higher than 5000.
thnx :)
PHP < 5.3:
preg_replace_callback('/\s*\d+\s*/', create_function('$a', 'return trim($a[0]) > 5000? " " : $a[0];'), $input);
PHP >= 5.3 (closure support):
preg_replace_callback('/\s*\d+\s*/', function ($a) {
return trim($a[0]) > 5000? " " : $a[0];
}, $input);
preg_replace('/\b0+((?!5000)[5-9]\d{3}|[1-9]\d{4,})(\.\d+)?/', '', $string);