扬帆☆启航

1、企业网站建设、推广、维护 2、中小型企业、店铺的业务管理系统(人事、工资、销售、库存管理、会员管理、统计查询、发票管理、客户关系管理,售后服务管理,物资管理等) 3、中小型企业信息化解决方案

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::
//验证Email地址 
  bool IsValidEmail(string strIn) 
  { 
   // Return true if strIn is in valid e-mail format. 
   return Regex.IsMatch(strIn, @"^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$");  
  } 

//验证是否为小数 
  bool IsValidDecimal(string strIn) 
  { 
    
   return Regex.IsMatch(strIn,@"[0].\d{1,2}|[1]");  
  } 

//验证年月日 
  bool IsValidDate(string strIn) 
  { 
   return Regex.IsMatch(strIn,@"^2\d{3}-(?:0?[1-9]|1[0-2])-(?:0?[1-9]|[1-2]\d|3[0-1])(?:0?[1-9]|1\d|2[0-3]):(?:0?[1-9]|[1-5]\d):(?:0?[1-9]|[1-5]\d)$");  
  } 

  //验证后缀名 
  bool IsValidPostfix(string strIn) 
  { 
   return Regex.IsMatch(strIn,@"\.(?i:gif|jpg)$");  
  } 

  //验证字符是否在4至12之间 
  bool IsValidByte(string strIn) 
  { 
   return Regex.IsMatch(strIn,@"^[a-z]{4,12}$");  
  } 

//验证IP 
  bool IsValidIp(string strIn) 
  { 
   return Regex.IsMatch(strIn,@"^(\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])$");  
  }  
posted on 2006-08-20 14:49  赵晓雷  阅读(166)  评论(0)    收藏  举报