var num = '21022332.05'
var exp = /^([1-9][\d]{0,7}|0)(\.[\d]{1,2})?$/
if(exp.test(num)){
alert('right')
}else{
alert('wrong')
}
</script>
可验证 大于等于零,小于等于99999999.99 的数字
测试正确
var s = '12345237987584564656,000.00'var d=s.replace(/(\d)(?=(\d{3})+(?!\d))/g, "$1,")
function getPrice(s) {s = s.match(/\d+(?:\.\d+)?元/)
// 如果没有匹配项,会返回空字符串
return s ? s[0] : ''
}
var price = getPrice('龙马仕 劲爽清透洁面乳120g*2支 天猫19.9元包邮')
alert(price) // 19.9元