This will alert 23.
alert(parseInt(\'23 asdf\'));
But this will not alert 23 but alerts NaN
alert(parseInt(\'asdf 23\'));
function toNumeric(string) { return parseInt(string.replace(/\D/g, ""), 10); }