Forum Moderators: coopster
Numeric strings consist of optional sign, any number of digits, optional decimal part and optional exponential part. Thus +0123.45e6 is a valid numeric value. Hexadecimal notation (0xFF) is allowed too but only without sign, decimal and exponential part.
For better checking, try the following:
[uk.php.net...]
dc
Javascript:
<input type="text" name="money" value="0.00" onkeyup="this.value = this.value.replace(/[^.,0-9]/g, '');" />
PHP:
$test_string = "USD $3.20 Please!";
echo preg_replace("/[^.,0-9]/e", "", $test_string); // 3.20
Added: There's probably a few dozen methods of doing this though, these are just my recent favorites. :)