const regex = /^(?![0,.]*$|0d*$)d{1,3}(?:,d{3})*(?:.d{1,2})?$/; [ "0", "012", "0.00", "0.0", "0.", "00122", "0.12", "0.01", "1,234.00", "1.00", "123,456", "1.23" ].forEach(s => console.log(`${s} --> ${regex.test(s)}`));