Regular Expressions common Regular Expressions

Source: Internet
Author: User
The four characters in the stenography skills of regular expressions are the regular expressions supported by all languages. Therefore, these four are the basic regular expressions. It is difficult to understand Regular Expressions because there is an equivalent concept in it, which greatly increases the difficulty of understanding and makes many beginners look confused. If the equivalence is restored to the original writing, writing regular expressions on your own is super simple, just like

The four characters in the stenography skills of regular expressions are the regular expressions supported by all languages. Therefore, these four are the basic regular expressions. It is difficult to understand Regular Expressions because there is an equivalent concept in it, which greatly increases the difficulty of understanding and makes many beginners look confused. If the equivalence is restored to the original writing, writing regular expressions on your own is super simple, just like

Skills in stenography for Regular Expressions

The four characters are regular expressions supported by all languages. Therefore, these four are basic regular expressions. It is difficult to understand Regular Expressions because there is an equivalent concept in it, which greatly increases the difficulty of understanding and makes many beginners look confused. If the equivalence is restored to the original writing, writing regular expressions on your own is super simple. You can write your regular expressions as you speak:


  Equivalent:
?, *, +, \ D, \ w are equivalent characters
? Equivalent to matching length {0, 1}
* Equivalent to the matching length {0 ,}
+ Equivalent to matching length {1 ,}
\ D is equivalent to [0-9]
\ W is equivalent to [A-Za-z_0-9].

Common operators and expressions:
  
^ Start
() Domain segment
[] Contains. By default, it is a single character length.
[^] Does not contain. The default value is one character length.
{N, m} matched Length
. Any single character (\. character point)
| Or
\ Escape
$ End
[A-Z] 26 uppercase letters
[A-z] 26 lowercase letters
[0-9] numbers 0 to 9

[A-Za-z0-9] 26 upper-case letters, 26 lower-case letters, and 0 to 9 digits
, Segmentation
  
  Segmentation Syntax:
[A, H, T, W] contains A, H, T, or W letters
[A, h, t, w] contains a, h, t, or w letters
[,] Contains 0, 3, 6, or 8 numbers


  Syntax and meaning:
  
Basic Syntax "^ ([] {}) ([] {}) ([] {}) $"
Regular string = "Start ([containing content] {length}) ([containing content] {length}) ([containing content] {length}) end"
  
?, *, +, \ D, \ w, which are all abbreviated and can be replaced by [] and (? :)(? = )(?!) (? <= )(? Can beginners ignore it ?, *, +, \ D, \ w, some abbreviated identifiers, learned to use the basic, and then replace the values by the table itself


  
  Instance:
String; tel: 086-0666-88810009999
Original regular expression: "^ tel: [0-9] {1, 3}-[0] [0-9] {2, 3}-[0-9] {8, 11} $"
Shorthand comprehension: Start "tel: plain text "[0-9 digits] {1 to 3 digits}"-plain text "[0 digits] [0-9 digits] {2 to 3 digits}"-plain text "[0-9 digits] {8 to 11 digits} ended"
Equivalent Abbreviation: "^ tel: \ d {1, 3}-[0] \ d {2, 3}-\ d {8, 11} $ ", the abbreviated syntax is not supported in all languages.


Common Regular Expressions
Intege: "^ -? [1-9] \ d * $ ", // integer intege1:" ^ [1-9] \ d * $ ", // positive integer intege2: "^-[1-9] \ d * $", // negative integer num: "^ ([+-]?) \ D *\\.? \ D + $ ", // number num1:" ^ [1-9] \ d * | 0 $ ", // positive number (positive integer + 0) num2: "^-[1-9] \ d * | 0 $", // negative (negative integer + 0) decmal: "^ ([+-]?) \ D *\\. \ d + $ ", // floating point decmal1:" ^ [1-9] \ d *. \ d * | 0. \ d * [1-9] \ d * $ ", // Positive floating point decmal:" ^-([1-9] \ d *. \ d * | 0. \ d * [1-9] \ d *) $ ", // negative floating point number decm_3:" ^ -? ([1-9] \ d *. \ d * | 0. \ d * [1-9] \ d * | 0 ?. 0 + | 0) $ ", // floating point decmal4:" ^ [1-9] \ d *. \ d * | 0. \ d * [1-9] \ d * | 0 ?. 0 + | 0 $ ", // non-negative floating point number (Positive floating point number + 0) decmal5:" ^ (-([1-9] \ d *. \ d * | 0. \ d * [1-9] \ d *) | 0 ?. 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 -./? % & =] *)? $ ", // Urlchinese:" ^ [\ u4E00-\ u9FA5 \ uF900-\ uFA2D] + $ ", // Chinese ascii only: "^ [\ x00-\ xFF] + $", // zipcode: "^ \ d {6} $", // mobile: "^ (13 | 15) [0-9] {9} $", // mobile ip4: "^ (25 [0-5] | 2 [0-4] \ d | [0-1] \ d {2} | [1-9]? \ D )\\. (25 [0-5] | 2 [0-4] \ d | [0-1] \ d {2} | [1-9]? \ D )\\. (25 [0-5] | 2 [0-4] \ d | [0-1] \ d {2} | [1-9]? \ D )\\. (25 [0-5] | 2 [0-4] \ d | [0-1] \ d {2} | [1-9]? \ D) $ ", // ip address notempty:" ^ \ S + $ ", // non-empty picture :"(. *)\\. (jpg | bmp | gif | ico | pcx | jpeg | tif | png | raw | tga) $ ", // image rar :"(. *)\\. (rar | zip | 7zip | tgz) $ ", // compressed file date:" ^ \ d {4} (\-|\/ | \.) \ d {1, 2} \ 1 \ d {1, 2} $ ", // Date qq: "^ [1-9] * [1-9] [0-9] * $", // QQ number tel: "^ ([0 \ +] \ d {2, 3 }-)? (0 \ d {2, 3 })-)? (\ D {7, 8}) (-(\ d {3 ,}))? $ ", // Telephone number function (including domestic area code, international area code, extension code) username:" ^ \ w + $ ", // used for user registration. Match A string consisting of digits, 26 English letters, or underscores (_): "^ [A-Za-z] + $", // letter letter_u: "^ [A-Z] + $", // uppercase letter letter_l: "^ [a-z] + $", // lowercase letter idcard: "^ [1-9] ([0-9] {14} | [0-9] {17}) $" // ID card

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.