namespace CommonTools { /**//// <summary> /// RegexLib 的摘要說明。 /// </summary> public class RegexLib {

//驗證Email地址 public stat " /> 99久久精品免费看国产免费软件,91精品国产九九九久久久亚洲,精品国产乱码久久久久久浪潮

色尼玛亚洲综合影院,亚洲3atv精品一区二区三区,麻豆freexxxx性91精品,欧美在线91

幾個C#常用正則表達式的總結

using System; 
using System.Text.RegularExpressions; 

namespace CommonTools 

/**//// <summary> 
/// RegexLib 的摘要說明。 
/// </summary> 
public class RegexLib 


//驗證Email地址 
public static 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})(/]?)$"); 

//dd-mm-yy 的日期形式代替 mm/dd/yy 的日期形式。 
public static string MDYToDMY(String input) 

return Regex.Replace(input,"http://b(?//d{1,2})/(?//d{1,2})/(?//d{2,4})//b","${day}-${month}-${year}"); 

//驗證是否為小數 
public static bool IsValidDecimal(string strIn) 

return Regex.IsMatch(strIn,@"[0]./d{1,2}|[1]"); 

//驗證是否為電話號碼 
public static bool IsValidTel(string strIn) 

return Regex.IsMatch(strIn,@"(/d+-)?(/d{4}-?/d{7}|/d{3}-?/d{8}|^/d{7,8})(-/d+)?"); 

//驗證年月日 
public static 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)$"); 

//驗證后綴名 
public static bool IsValidPostfix(string strIn) 

return Regex.IsMatch(strIn,@"/.(?i:gif|jpg)$"); 

//驗證字符是否再4至12之間 
public static bool IsValidByte(string strIn) 

return Regex.IsMatch(strIn,@"^[a-z]{4,12}$"); 

//驗證IP 
public static 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])$"); 




AspNet技術幾個C#常用正則表達式的總結,轉載需保留來源!

鄭重聲明:本文版權歸原作者所有,轉載文章僅為傳播更多信息之目的,如作者信息標記有誤,請第一時間聯系我們修改或刪除,多謝。

主站蜘蛛池模板: 陇西县| 宕昌县| 长寿区| 阜康市| 扶风县| 唐海县| 阿克陶县| 永兴县| 阳原县| 盈江县| 上蔡县| 广昌县| 海晏县| 白玉县| 福清市| 文水县| 临泽县| 绥棱县| 民县| 周至县| 枞阳县| 莫力| 翼城县| 哈巴河县| 金昌市| 饶河县| 和田县| 塔城市| 黄石市| 彩票| 浏阳市| 安阳县| 左贡县| 阜阳市| 册亨县| 西乡县| 油尖旺区| 石嘴山市| 德惠市| 昌图县| 海兴县|