Common Regular Expressions

Source: Internet
Author: User

Intege: "^-?" [1-9]\\d*$],//integer

Intege1: "^[1-9]\\d*$",//Positive integer

Intege2: "^-[1-9]\\d*$",//Negative integer
Num: "^ ([+-]?) \\d*\\.? \\d+$ ",//Digital
NUM1: "^[1-9]\\d* |0$",//positive number (positive integer + 0)
NUM2: "^-[1-9]\\d* |0$",//negative number (negative integer + 0)
Decmal: "^ ([+-]?) \\d*\\.\\d+$ ",//floating point
Decmal1: "^[1-9]\\d*.\\d* |0.\\d*[1-9]\\d*$",//positive floating point
Decmal2: "^-([1-9]\\d*.\\d* |0.\\d*[1-9]\\d*) $",//negative floating-point number
DECMAL3: "^-?" ([1-9]\\d*.\\d* |0.\\d*[1-9]\\d* | 0+ |) $ ",//floating point
Decmal4: "^[1-9]\\d*.\\d* |0.\\d*[1-9]\\d* | 0+ |0$ ",//non-negative floating point number (positive floating point + 0)
DECMAL5: "^ (-([1-9]\\d*.\\d* |0.\\d*[1-9]\\d*)] | 0+ |0$ ",//non-positive floating-point number (negative floating-point number + 0)

Email: "^\\w+ ((-\\w+) | ( \\.\\w+)) *\\@[a-za-z0-9]+ ((\ \ | |) [a-za-z0-9]+) *\\. [a-za-z0-9]+$],//Mail
Color: "^[a-fa-f0-9]{6}$",//Color
URL: "^http[s]?:\ \/\\/([\\w-]+\\.) +[\\w-]+ ([\\w-./?%&=]*)? $ ",//url
Chinese: "^[\\u4e00-\\u9fa5\\uf900-\\ufa2d]+$",//Chinese only
ASCII: "^[\\x00-\\xff]+$",//only acsii characters
ZipCode: "^\\d{6}$",//ZIP code
Mobile: "^ (13 |15) [0-9]{9}$",//Mobile
IP4: "^ (\\d{1,2} |1\\d\\d |2[0-4]\\d |25[0-5]). (\\d{1,2} |1\\d\\d |2[0-4]\\d |25[0-5]). (d{1,2} |1\\d\\d |2[0-4]\\d |25[0-5]). (\\d{1,2} |1\\d\\d |2[0-4]\\d |25[0-5]) $ ",//IP address
Notempty: "^\\s+$",//Non-empty
Picture: "(. *) \ \. (jpg |bmp |gif |ico |pcx |jpeg |tif |png |raw |tga) $ ",//Picture
RAR: "(. *) \ \. (RAR |zip |7zip |tgz) $ ",//Zip file
Date: "(([0-9]{3}[1-9] |[ 0-9]{2}[1-9][0-9]{1} | [0-9] {1} [1-9] [0-9] {2} | [1-9] [0-9] {3}) -(((0[13578] |1[02])-(0[1-9] |[ 12][0-9] |3[01]) | ((0[469] |11)-(0[1-9] |[ 12][0-9] |30) | (02-(0[1-9] |[ 1][0-9] |2[0-8))) | (([0-9]{2}) (0[48] |[ 2468][048] | [13579] [26]) | ((0[48] | [2468] [048] | [3579] [26]) 00))-02-29),//Date
QQ: "^[1-9]*[1-9][0-9]*$",//qq number
Tel: "(\\d{3}-|\\d{4}-)? (\\d{8} |\\d{7}) ",//Domestic phone
Username: "^\\w+$",//used for user registration. Matches a string consisting of a number, 26 letters, or underscores
Letter: "^[a-za-z]+$",//Letters
Letter_u: "^[a-z]+$",//capital letters
letter_l: "^[a-z]+$",//lowercase letters
Idcard: "^[1-9" ([0-9]{14} |[ 0-9]{17}) $ "//ID

Common Regular Expressions

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.