C # Regular Expression verification,
Public class VerifyUtil {// <summary> // judge that the input string contains only Chinese characters /// </summary> /// <param name = "input"> </ param> // <returns> </returns> public static bool IsChineseCh (string input) {return Regex. isMatch (input, @ "^ [\ u4e00-\ u9fa5] + $");} // <summary> // the phone number that matches the three-digit or four-digit area code, the area code can be enclosed in parentheses, // or not. The area code and the local code can be separated by a hyphen or space, /// or no interval // \ (0 \ d {2} \) [-]? \ D {8} | 0 \ d {2} [-]? \ D {8} | \ (0 \ d {3} \) [-]? \ D {7} | 0 \ d {3} [-]? \ D {7} /// </summary> /// <param name = "input"> </param> /// <returns> </returns> public static bool isPhone (string input) {string pattern = "^ \ (0 \ d {2} \) [-]? \ D {8 }$ | ^ 0 \ d {2} [-]? \ D {8 }$ | ^ \ (0 \ d {3} \) [-]? \ D {7 }$ | ^ 0 \ d {3} [-]? \ D {7} $ "; return Regex. isMatch (input, pattern );} /// <summary> /// determines whether the input string is a valid mobile phone number. /// </summary> /// <param name = "input"> </param> /// <returns> </returns> public static bool IsMobilePhone (string input) {return Regex. isMatch (input, @ "^ 1 {3, 5, 8} \ d {9} $ ");} /// <summary> /// determines that the input string only contains numbers. /// it can match integers and floating-point numbers. /// ^ -? \ D + $ | ^ (-? \ D +) (\. \ d + )? $ // </Summary> /// <param name = "input"> </param> /// <returns> </returns> public static bool IsNumber (string input) {string pattern = @ "^ -? \ D + $ | ^ (-? \ D +) (\. \ d + )? $ "; Return Regex. isMatch (input, pattern );} /// <summary> /// determines whether the input string is a valid Email address. /// </summary> /// <param name = "input"> </param >/// <returns> </returns> public static bool IsEmail (string input) {string pattern = @ "^ ([\ w-\.] +) @ (\ [0-9] {1, 3 }\. [0-9] {1, 3 }\. [0-9] {1, 3 }\.) | ([\ w-] + \.) +) ([a-zA-Z] {2, 4} | [0-9] {1, 3}) (\]?) $ "; Return Regex. isMatch (input, pattern );} /// <summary> /// determines whether the input string is a hyperlink. /// </summary> /// <param name = "input"> </param> // /<returns> </returns> public static bool IsURL (string input) {string pattern = @ "^ [a-zA-Z] +: // (\ w + (-\ w + )*)(\. (\ w + (-\ w + )*))*(\? \ S *)? $ "; Return Regex. IsMatch (input, pattern );}}