Common Regular Expression check

Source: Internet
Author: User

[Csharp]
Private static Regex RegPhone = new Regex ("^ [0-9] + [-]? [0-9] + [-]? [0-9] {1} $ ");
Private static Regex RegNumber = new Regex ("^ [0-9] + {1} $ ");
Private static Regex RegNumberSign = new Regex ("^ [+-]? [0-9] + {1} $ ");
Private static Regex RegDecimal = new Regex ("^ [0-9] + [.]? [0-9] + {1} $ ");
Private static Regex RegDecimalSign = new Regex ("^ [+-]? [0-9] + [.]? [0-9] + {1} $ "); // equivalent to ^ [+-]? \ D + [.]? \ D + $
Private static Regex RegEmail = new Regex ("^ [\ w-] + @ [\ w-] + \\. (com | net | org | edu | mil | TV | biz | info) {1} $ "); // a string of letters or numbers, the same as the [a-zA-Z0-9] syntax
Private static Regex RegCHZN = new Regex ("[\ u4e00-\ u9fa5]"); // specifies whether Chinese characters are available

Example:

 

[Csharp]
# Region Chinese Detection
 
/// <Summary>
/// Check for Chinese Characters
/// </Summary>
/// <Param name = "inputData"> </param>
/// <Returns> </returns>
Public static bool IsHasCHZN (string inputData)
{
Match m = RegCHZN. Match (inputData );
Return m. Success;
}
 
# Endregion


From the column keenweiwei

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.