[英]Regular Expression to match more than 1 decimal point
I am trying to support the following formats: 我正在尝试支持以下格式:
11.11
01.67
30.03
11.45.23
But the Regex i used "/^[+-]?([0-9]*\\.?[0-9]+|[0-9]+\\.?[0-9]*)([eE][+-]?[0-9]+)?$/"
supports only first 3 formats. 但是正则表达式我使用了
"/^[+-]?([0-9]*\\.?[0-9]+|[0-9]+\\.?[0-9]*)([eE][+-]?[0-9]+)?$/"
仅支持前3种格式。
I need to match numbers with 1 or more decimal points like 11.12.36 我需要将数字与1个或多个小数点相匹配,例如11.12.36
Please help me out! 请帮帮我!
Try this. 尝试这个。
sPattern = @"^\d{2}\.\d{2}(\.\d{2})*$";
it will include all numbers 它将包括所有数字
11.11
23.45.57
12.54.78.78
If you want to allow any number of digits between your decimal points and any number of decimal points including a possible starting decimal point you could try something like: 如果要允许小数点和小数点之间的任意位数,包括可能的起始小数点,可以尝试如下操作:
\.?\d+(?:\.\d+)*
This will allow things like .123 123.123 123.123.123.123 etc 这将允许.123 123.123 123.123.123.123等
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.