国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > C# > 正文

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

2024-09-07 17:05:21
字體:
來源:轉載
供稿:網友
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])$"); 




發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 瑞金市| 涡阳县| 喀喇| 密山市| 阳东县| 大足县| 古丈县| 招远市| 农安县| 阿合奇县| 友谊县| 福安市| 新郑市| 老河口市| 浦县| 南溪县| 建德市| 四川省| 民权县| 托克逊县| 积石山| 博罗县| 台安县| 剑河县| 林西县| 连城县| 苍溪县| 深泽县| 嘉祥县| 调兵山市| 武功县| 深圳市| 武威市| 河北省| 贵德县| 新丰县| 白沙| 石河子市| 双江| 临清市| 巴中市|