Using System; Using System.Text.RegularExpressions; namespace Commontools {/**////<summary>///Regexlib Summary description. </summary> public class Regexlib {//Verify email address public static bool IsValidEmail (string strin) {//Return T Rue 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}) (\]?) $"); } The date form of//dd-mm-yy instead of the Mm/dd/yy date form. public static string Mdytodmy (string input) {return Regex.Replace (input, "\\b (? \\d{1,2})/(? \\d{1,2})/(? \\d{2,4}) \\b", "${day}-${month}-${year}"); }//Verify whether it is a decimal public static bool Isvaliddecimal (string strin) {return Regex.IsMatch (strin,@ "[0].\d{1,2}|[ 1] "); }//Verify is the phone number public static bool Isvalidtel (string strin) {return Regex.IsMatch (strin,@ "(\d+-)? ( \d{4}-?\d{7}|\d{3}-?\d{8}|^\d{7,8}) (-\d+)? "); Verify that the month and day 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) $ "); }//Verify the suffix name public static bool Isvalidpostfix (string strin) {return regex.ismatch (strin,@ "\. i:gif|jpg) $ "); }//Verify if the character is between 4 and 12 public static bool Isvalidbyte (string strin) {return Regex.IsMatch (strin,@ "^[a-z]{4,12}$"); }//Verify 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]) $ "); } } }