Simple regular expression for a decimal with a precision of 2

后端 未结 17 2051
闹比i
闹比i 2020-11-22 02:02

What is the regular expression for a decimal with a precision of 2?

Valid examples:

123.12
2
56754
92929292929292.12
0.21
3.1
17条回答
  •  名媛妹妹
    2020-11-22 02:44

    This worked with me:

    (-?[0-9]+(\.[0-9]+)?)
    

    Group 1 is the your float number and group 2 is the fraction only.

提交回复
热议问题