Simple regular expression for a decimal with a precision of 2

后端 未结 17 2073
闹比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:51

    This will allow decimal with exponentiation and upto 2 digits ,

    ^[+-]?\d+(\.\d{2}([eE](-[1-9]([0-9]*)?|[+]?\d+))?)?$
    

    Demo

提交回复
热议问题