return only digits from a string
Posted: Sun Jan 03, 2010 2:34 am
im trying to get the numeric component of a css width and height attribute. but apparently im either regextarded or javascriptarded.
WAIT NEVERMIND
THIS IS RETARDED
NO GOOD
NO GOOD
BEANS
im so angry.
WAIT NEVERMIND
THIS IS RETARDED
Code: Select all
function _trim_chars(string)
{
var regex = new RegExp("/\D/g");
return string.replace(regex, "");
}
alert(_trim_chars("f98u2j304fj04"));
Code: Select all
function _trim_chars(string)
{
var regex = new RegExp("/[^0-9]/g");
return string.replace(regex, "");
}
alert(_trim_chars("f98u2j304fj04"));
Code: Select all
function _trim_chars(string)
{
var regex = new RegExp(/[^0-9]/g);
return string.replace(regex, "");
}
im so angry.