you can use
let regex = new RegExp(
^(?=[0-9.]{1,${maxlength}}$)[0-9]+(?:\.[0-9]{0,${decimal_number}})?$
);
where you can decide the maximum length and up to which decimal point you want to control the value
Use ES6 String interpolation to wrap the variables ${maxlength} and ${decimal_number}.