SOURCE

// 保留几位小数的正则表达式
 oninput="if(isNaN(value)) {if (value.match(/\d+[(\.)(\d+)]?/g)) {value=value.match(/\d+[(\.)(\d+)]?/g)[0]}else{value=null}} value=value.replace(/^(\-)*(\d+)\.(\d\d\d\d).*$/,'$1$2.$3')"



//  好用
val.replace(/^\D*(\d*(?:\d{0,2})?).*$/g, '$1')
console 命令行工具 X clear

                    
>
console