常用字元驗證與過濾函式

2021-04-07 02:26:32 字數 2511 閱讀 9166

使用者許可權:版主

使用者積分:232

public class validation

#endregion

private  static string str;

/// 

/// 常用過濾字元

///防止注入攻擊

/// 

public static string  isvalidsting(string strin)

/// 

/// 常用還原字元

/// 

public static string  isvalidtosting(string strin)

/// 

/// 有效密碼檢驗

/// 

public static bool isvalidpassword(string strin)

else }

/// 

/// 有效電子郵件格式檢驗

/// 

public static bool isvalidemail(string strin)

/.[0-9]/.[0-9]/.)|(([/w-]+/.)+))([a-za-z]|[0-9])(/]?)$"); 

} /// 

/// 有效url檢驗

/// 

public static bool isvalidurl(string strin)

/// 

/// 有效日期檢驗 如2005-9-2

/// 基本上把閏年和2月等的情況都考慮進去了

/// 

public static bool isvaliddate(string strin)

)-(0?[13578]|1[02])-(0?[1-9]|[12]/d|3[01]))|(((1[6-9]|[2-9]/d)/d)-(0?[13456789]|1[012])-(0?[1-9]|[12]/d|30))|(((1[6-9]|[2-9]/d)/d)-0?2-(0?[1-9]|1/d|2[0-8]))|(((1[6-9]|[2-9]/d)(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00))-0?2-29-))$"); 

} /// 

/// 有效長日期檢驗 如2005-9-2 13:20:37

/// 基本上把閏年和2月等的情況都考慮進去了

/// 

public static bool isvaliddatelong(string strin)

)-(0?[13578]|1[02])-(0?[1-9]|[12]/d|3[01]))|(((1[6-9]|[2-9]/d)/d)-(0?[13456789]|1[012])-(0?[1-9]|[12]/d|30))|(((1[6-9]|[2-9]/d)/d)-0?2-(0?[1-9]|1/d|2[0-8]))|(((1[6-9]|[2-9]/d)(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00))-0?2-29-)) (20|21|22|23|[0-1]?/d):[0-5]?/d:[0-5]?/d$"); 

} /// 

/// 有效身份證檢驗

/// 

public static bool isvalidpcode(string strin)

)+$");

} /// 

/// 有效**檢驗 

/// 如0599-1234567-0000 或 0599-1234567 等

/// 

public static bool isvalidtel(string strin)

|/d)-(/d|/d))|((/d|/d)-(/d|/d)-(/d)))$");

} /// 

/// 有效整數檢驗

/// 

public static bool isvalidint(string strin)

/// 

/// 有效英文檢驗

/// 

public static bool isvalidenglish(string strin)

/// 

/// 有效中文檢驗

/// 

public static bool isvalidchinese(string strin)

/// 

/// 有效英文-數字檢驗

/// 

public static bool isvalidenglishint(string strin)

/// 

/// 有效中文-數字檢驗

/// 

public static bool isvalidchineseint(string strin)

/// 

/// 有效中文-英文-數字檢驗

/// 

public static bool isvalidchineseenglishint(string strin) }

正規表示式之常用字元驗證技巧

一 使用正規表示式檢查字串中重複出現的詞,截圖 二 using system using system.collections.generic using system.componentmodel using system.data using system.drawing using syste...

後端常用欄位驗證

驗證郵箱 public static boolean isemail string input return pattern.matches reg,input 驗證手機號 public static boolean isphone string input 0 d d 0 d d return p...

python常用字串 Python常用字串操作

1.字串首字母大寫 2.統計字串中某個字母的個數 統計字串中某個字母的個數又分兩種情況,在整個字串中統計和在某個索引範圍內統計 1 在整個字串中統計,如下面統計字串str2中字母a的個數 2 在某個索引區間內統計,如下面統計字串str2索引1到10和1到30範圍內字母t的個數 3.求字串的長度 4....

mysql常用字串 MYSQL常用字串函式寶典

mysql常用字串函式 想更進一步加強自己在查詢語句方面的能力,需要掌握常用函式。字串函式 1 concat s1,s2,sn 將s1,s2,sn串聯成一個字串。exp root test 14 43 desc t1 field type null key default extra id int ...

ORACLE 常用字元函式

1.lower lower str 強制小寫 2.upper upper str 強制大寫 3.initcap initcap str 每個單詞首字母大寫 示例 sql select initcap my boy from dual 返回 my boy 注意 單詞之間用下劃線 分割 4.concat...