let reg = /(^[1-9](d+)?(.d{1,2})?$)|(^[1-9]$)|(^d.[1-9]{1,2}$)|(^d.[0]{1}[1-9]{1}$|(^d.[1-9]{1}[0]{1}$)$)/; let num = 0.01; if (reg.exec(num)) { console.log('验证通过'); } else { console.log('验证失败'); }