[C #] Helper encapsulation series,
Using System; using System. collections. generic; using System. linq; using System. text; using System. text. regularExpressions; using System. threading. tasks; namespace ConsoleApplication6 {public sealed class RegularExpressionHelper {// <summary> // indicates whether the mobile phone number is valid /// </summary> /// <param name = "input"> Yes search for the matching string </param> /// <returns> If the regular expression finds a match, true; otherwise, false </returns> public static bool IsPhone (string input) {return Regex. isMatch (input, @ "^ [1] [358] \ d {9} $ ");} /// <summary> /// valid ID card number /// </summary> /// <param name = "input"> string to search for matching items </ param> // <returns> If the regular expression finds a match, true; otherwise, false </returns> public static bool IsIdCard (string input) {return Regex. isMatch (input, @ "^ (^ \ d {15 }$ | ^ \ d {18 }$ | ^ \ d {17} (\ d | X | x )) $ ", RegexOptions. ignoreCase );} /// <summary> /// whether the postal code is legal /// </summary> /// <param name = "input"> string to search for matching items </ param> // <returns> If the regular expression finds a match, true; otherwise, false </returns> public static bool IsPostCard (string input) {return Regex. isMatch (input, @ "^ [1-9] \ d {5} $ ");} /// <summary> /// check whether the email address is valid /// </summary> /// <param name = "input"> Search for the matching string </param> /// <returns> If the regular expression finds a match, true; otherwise, false </returns> public static bool IsEMail (string input) {return Regex. isMatch (input, @ "^ \ w + ([-+.] \ w +) * @ \ w + ([-.] \ w + )*\. \ w + ([-.] \ w +) * $ ");}}}