C # Regular Expression validation

Source: Internet
Author: User

 Public classVerifyutil {/// <summary>        ///the input string is judged to contain only Chinese characters/// </summary>        /// <param name= "input" ></param>        /// <returns></returns>         Public Static BOOLIschinesech (stringinput) {            returnRegex.IsMatch (Input,@"^[\u4e00-\u9fa5]+$"); }        /// <summary>        ///a phone number that matches the 3-bit or 4-bit area code, where the area code can be enclosed in parentheses .///You can also use a hyphen or a space between the area code and the local number .///You can also have 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 BOOLIsphone (stringinput) {            stringPattern ="^\\ (0\\d{2}\\) [-]?\\d{8}$|^0\\d{2}[-]?\\d{8}$|^\\ (0\\d{3}\\) [-]?\\d{7}$|^0\\d{3}[-]?\\d{7}$"; returnRegex.IsMatch (Input,pattern); }        /// <summary>        ///determines whether the input string is a legitimate phone number/// </summary>        /// <param name= "input" ></param>        /// <returns></returns>         Public Static BOOLIsmobilephone (stringinput) {            returnRegex.IsMatch (Input,@"^1{3,5,8}\\d{9}$"); }        /// <summary>        ///the input string is judged to contain only numbers///can match integers and floating-point numbers///^-?\d+$|^ (-?\d+) (\.\d+)? $/// </summary>        /// <param name= "input" ></param>        /// <returns></returns>         Public Static BOOLIsnumber (stringinput) {            stringPattern =@"^-?\d+$|^ (-?\d+) (\.\d+)? $"; returnRegex.IsMatch (input, pattern); }        /// <summary>        ///determine if the input string is a valid email address/// </summary>        /// <param name= "input" ></param>        /// <returns></returns>         Public Static BOOLIsemail (stringinput) {            stringPattern =@"^ ([\w-\.] +) @ ((\[[0-9]{1,3}\. [0-9] {1,3}\. [0-9] {1,3}\.) | ([\w-]+\.) +)) ([a-za-z]{2,4}| [0-9] {1,3}) (\]?) $"; returnRegex.IsMatch (input, pattern); }        /// <summary>        ///determines whether the input string is a hyperlink/// </summary>        /// <param name= "input" ></param>        /// <returns></returns>         Public Static BOOLIsurl (stringinput) {            stringPattern =@"^[a-za-z]+://(\w+ (-\w+) *) (\. ( \w+ (-\w+) *) * (\?\s*)? $"; returnRegex.IsMatch (Input,pattern); }    }

C # Regular Expression validation

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.