码迷,mamicode.com
首页 > 其他好文 > 详细

Ip地址验证与价格验证

时间:2014-06-18 10:35:56      阅读:193      评论:0      收藏:0      [点我收藏+]

标签:string   name   new   res   io   public   

1、Ip地址验证
/// <summary>
/// Ip地址验证
/// </summary>
public static bool CheckIp(string ip)
{
bool result = false;
Regex ipReg = new Regex(@"^(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])$");
if (ipReg.IsMatch(ip))
{
result = true;
}
return result;
}

2、价格验证

/// <summary>
/// 价格验证
/// </summary>
/// <param name="priceStr"></param>
/// <returns></returns>
public bool CheckPrice(string priceStr)
{
bool result = false;
Regex regex = new Regex(@"^\d+(\.\d{1,2})?$", RegexOptions.IgnoreCase);
Match match = regex.Match(priceStr);
if (match.Success)
{
result = true;
}
return result;
}

Ip地址验证与价格验证,布布扣,bubuko.com

Ip地址验证与价格验证

标签:string   name   new   res   io   public   

原文地址:http://www.cnblogs.com/Devil1314/p/3793180.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!