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

//驗證Email地址 public stat " /> 欧美日韩亚洲一区二区三区四区,国产精品电影网站,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#常用正則表達式的總結,轉載需保留來源!

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

主站蜘蛛池模板: 通辽市| 循化| 铁岭市| 华亭县| 武定县| 应城市| 定安县| 淅川县| 博客| 剑阁县| 南部县| 顺昌县| 峡江县| 芷江| 涟源市| 隆林| 新郑市| 吴忠市| 远安县| 隆化县| 青岛市| 通海县| 兴义市| 灌云县| 永泰县| 武汉市| 沙坪坝区| 砀山县| 福建省| 二连浩特市| 潍坊市| 江津市| 金寨县| 平凉市| 高安市| 布尔津县| 上高县| 峨眉山市| 新河县| 宁南县| 略阳县|