import { cloneDeep } from "lodash-es";
//只能输入数字和小数点，否则为0
export const useValidateInput = (value: any) => {
    let valueClone = cloneDeep(value) + "";
    //只能输入1-9和小数点，并且第一位不能为小数点
    let replaceValue = valueClone
        .replace(/^\.+/g, "0.")
        .replace(/[^\d^\\.]+/g, "")
        .replace(".", "$#$")
        .replace(/\./g, "")
        .replace("$#$", ".");
    //禁止输入多个小数点
    let resultValue = replaceValue.replace(/^(\\-)*(\d+)\.(\d\d\d\d\d\d\d\d\d\d).*$/, "$1$2.$3");
    return resultValue;
};
