[C #] Helper encapsulation series,

Source: Internet
Author: User

[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 +) * $ ");}}}

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.