验证decimal(4,2),decimal(5,2),decimal(2,1),int类型,字符串长度等。
//验证是否为dec(5,2)小数
public bool IsValidDecimal5_2(string strIn)
{ //return Regex.IsMatch(strIn, @"[0].\d{1,2}|[1]");
return Regex.IsMatch(strIn, @"[0-150].\d{0,2}}");
} //验证是否为dec(4,2)小数
public bool IsValidDecimal4_2(string strIn)
{ //return Regex.IsMatch(strIn, @"[0].\d{1,2}|[1]");
return Regex.IsMatch(strIn, @"[0-99].\d{0,2}");
} //验证是否为dec(4,2)小数
public bool IsValidDecimal2_1(string strIn)
{ //return Regex.IsMatch(strIn, @"[0].\d{1,2}|[1]");
return Regex.IsMatch(strIn, @"[0-9].\d{0,1}");
} //验证是否为int类型整数
public bool IsValidInt(string strIn)
{ //return Regex.IsMatch(strIn, @"[0].\d{1,2}|[1]");
return Regex.IsMatch(strIn, @"\d");
}
就一个decimal(2,1)的好用,搞不懂了,求教~~
//验证是否为dec(5,2)小数
public bool IsValidDecimal5_2(string strIn)
{ //return Regex.IsMatch(strIn, @"[0].\d{1,2}|[1]");
return Regex.IsMatch(strIn, @"[0-150].\d{0,2}}");
} //验证是否为dec(4,2)小数
public bool IsValidDecimal4_2(string strIn)
{ //return Regex.IsMatch(strIn, @"[0].\d{1,2}|[1]");
return Regex.IsMatch(strIn, @"[0-99].\d{0,2}");
} //验证是否为dec(4,2)小数
public bool IsValidDecimal2_1(string strIn)
{ //return Regex.IsMatch(strIn, @"[0].\d{1,2}|[1]");
return Regex.IsMatch(strIn, @"[0-9].\d{0,1}");
} //验证是否为int类型整数
public bool IsValidInt(string strIn)
{ //return Regex.IsMatch(strIn, @"[0].\d{1,2}|[1]");
return Regex.IsMatch(strIn, @"\d");
}
就一个decimal(2,1)的好用,搞不懂了,求教~~
解决方案 »
- C#form画面:如何控制自定义控件内的子控件的光标?
- 关于word控制的问题!Merge的用法
- 初学C#,Win Form的问题
- treeview 问题 找不到文件或程序集名称“Microsoft.Web.UI.WebControls”
- 修改用户名与密码
- 如何检查一个文本框中含有(逗号),并在逗号关插入换行
- C#程序调用外部程序(Python程序)并后台执行外部程序button按钮事件,烦请高手进来指导指导
- 请教一个关于程序启动路径的问题
- 做了一个POP3客户端组件,关心此问题的朋友近来探讨一下。
- 怎样改变窗口标题条颜色?
- 一个datagridview绑定数据集合的问题
- 求mapxtreme2008 v6.8下载地址
public bool IsValidDecimal5_2(string strIn)
{
return Regex.IsMatch(strIn, @"\d{5}\.\d{2}");
} //验证是否为dec(4,2)小数
public bool IsValidDecimal4_2(string strIn)
{
return Regex.IsMatch(strIn, @"\d{4}\.\d{2}");
} //验证是否为int类型整数
public bool IsValidInt(string strIn)
{
return Regex.IsMatch(strIn, @"\d+");
}
public bool IsValidDecimal5_2(string strIn)
{
return Regex.IsMatch(strIn, @"\d{1,3}\.\d{0,2}");
} //验证是否为dec(4,2)小数
public bool IsValidDecimal4_2(string strIn)
{
return Regex.IsMatch(strIn, @"\d{1,2}\.\d{0,2}");
} //验证是否为int类型整数
public bool IsValidInt(string strIn)
{
return Regex.IsMatch(strIn, @"\d+");
}
//验证是否为dec(5,2)小数
public bool IsValidDecimal5_2(string strIn)
{
return Regex.IsMatch(strIn, @"^[+-]?(?=([0-9]{1,5}$|[0-9.]{3,6}$))(0|[1-9][0-9]{0,4})(\.[0-9]{1,2})?$",RegexOptions.ExplicitCapture);
} //验证是否为dec(4,2)小数
public bool IsValidDecimal4_2(string strIn)
{
return Regex.IsMatch(strIn, @"^[+-]?(?=([0-9]{1,4}$|[0-9.]{3,5}$))(0|[1-9][0-9]{0,3})(\.[0-9]{1,2})?$", RegexOptions.ExplicitCapture);
} //验证是否为dec(2,1)小数
public bool IsValidDecimal2_1(string strIn)
{
return Regex.IsMatch(strIn, @"^(?=([0-9]{1,2}$|[0-9.]{3}$))(0|[1-9][0-9]{0,1})(\.[0-9])?$", RegexOptions.ExplicitCapture);
} //验证是否为int类型整数
public bool IsValidInt(string strIn)
{
return Regex.IsMatch(strIn, @"^[+-]?(0|[1-9][0-9]*)$", RegexOptions.ExplicitCapture);
}
还是得谢谢你的热心帮助