Regex number amount validation
问题 I want to validate the amount with the below scenario. The below regex is working except ',' for example 1,000.0000 ^(?!0*(\.0+)?$)(\d*(?:\.[0-9]{0,4})?)$ 1 - should pass 0.1 - should pass .1 - should pass 0 - should fail .0001 - should pass .10 - should pass 0.0 - should fail 0.00000 - should fail (only accept 4 digits after the decimal point) 1.0000 - should pass 1,000.0000 - should pass 1,000,00.000 - should pass 1,000.0000 - should pass 回答1: ^(?![0,]*(\.0+)?$)([,\d]*(?:\.[0-9]{0,4})?)$ .