What's a C# regular expression that'll validate currency, float or integer?

前端 未结 8 2404
闹比i
闹比i 2020-12-06 12:21

What is a regular expression suitable for C# that\'ll validate a number if it matches the following?

 $1,000,000.150
 $10000000.199
 $10000 
 1,         


        
8条回答
  •  再見小時候
    2020-12-06 13:16

    You can use csmba's regex if you make one slight modification to it.

    ^\$?(\d{1,3},?(\d{3},?)*\d{3}(.\d{0,3})?|\d{1,3}(.\d{2})?)$
    

提交回复
热议问题