[英]Regular expression for validating numeric(6,2)
I am using SQL Server 2008. I have a numeric column for numeric(6,2). 我正在使用SQL Server2008。我有一个用于numeric(6,2)的数字列。 For which I have a regular expression for 6 digit number with optional 2 decimal digit:
为此,我有一个6位数字的正则表达式和可选的2个十进制数字:
[RegularExpression(@"^\d{0,4}(\.\d{0,2})?$", ErrorMessage = "Must be number with maximum 2 decimal places & maximum 7 characters.")]
public decimal? PALLET_W { get; set; }
This allow all the below values: 这允许以下所有值:
1234.34, 345.45, 45.5, 4.5, 1234 1234.34、345.45、45.5、4.5、1234
But, It does not allow these values: 123456, 12364.7 但是,它不允许这些值:123456,12364.7
My main requirement is maximum 7 characters with optional 2 decimal digit. 我的主要要求是最多7个字符,可选2个十进制数字。
So, I need to allow these values too: 123456, 12364.7 因此,我也需要允许这些值:123456、12364.7
Is there any way to do so? 有什么办法吗?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.