开发者

Decimal format in Regular Expression

开发者 https://www.devze.com 2023-03-14 09:34 出处:网络
In winforms, I use Regular expression to check decimal format. Pl开发者_如何学Pythonease check whether my format is correct or not.

In winforms, I use Regular expression to check decimal format. Pl开发者_如何学Pythonease check whether my format is correct or not.

For example

123456.1234 

"^{0,1}[0-9]{0,1}[0-9]{0,1}[0-9]{0,1}[0-9]{0,1}[0-9]{0,1}[.]{0,1}[0-9]{0,1}[0-9]{0,1}[0-9]{0,1}$"

Is there any better format?

Actually I just wanna get 6 numeric and 4 decimal points only. How to format it?


Wouldn't ^\d+(\.\d)?$ be better?

This check for a number at the start of the string, then maybe a . followed by another number.

0

精彩评论

暂无评论...
验证码 换一张
取 消