正则匹配整数或小数

/^[0-9]+(.?[0-9]+)?$/

*代表{0,} +代表{1,} ?代表{0,1}

js中使用,

let reg = /^[0-9]+(.?[0-9]+)?$/;
if (!reg.test(amount)) {
    return tips.showMsg("输入格式有误");
}
原文地址:https://www.cnblogs.com/jiqing9006/p/12204498.html