Regular expression for positive decimal number with 0, 1 or 2 decimal places

后端 未结 5 1752
终归单人心
终归单人心 2021-01-16 11:48

Please help me make regular expression for positive decimal number with 0, 1 or 2 decimal places. It must allow comma and dot. For example it must allow:

0,0         


        
5条回答
  •  不要未来只要你来
    2021-01-16 12:12

    you can use the bracket notion to limit the number of digits:

    \d{0,2} would mean any run of digits from a minimum of 0 to a maximum of 2

提交回复
热议问题