Reading Notes for Regular Expressions

Source: Internet
Author: User

Recently, due to work needs, I read "regular expression must know" again. This is a small book that will soon be completed. I have a deeper understanding of regular expressions, which is indeed very powerful and worth learning.

The results are summarized as follows:

Two purposes of a regular expression: Search and replacement


. Match any single character [] Character Set combination Interval -Hyphens ^ Do not match

Special metacharacters: [\ B] rollback \ F page feed \ N linefeed \ R carriage return \ T Tab \ V vertical Tab \ D any number character [0-9] \ D [^ 0-9] \ W [a-zA-Z0-9 _] \ W [^ a-zA-Z0-9 _] \ S [\ f \ n \ r \ t \ v] \ S [^ \ f \ n \ r \ t \ v] + Match one or more characters * Matches zero or multiple characters. ? Matches zero or one character {N} exact match appears n times {N, m} exact match n to m times {N,} matches at least N times The above methods are greedy, as long as one is added after ?, Become lazy Limits: \ B specifies the word boundary \ B specifies not the word boundary ^ Starts with a string $ End of string ? M. The sequence of metacharacters that change the behavior of other metacharacters must appear at the beginning of the entire mode. \ N backtracking reference $1 replacement with backend reference ? = Forward search,? = Indicates the child expression starting with ", that is, whether the final content exists in the matching range ." ? <= Backward Search ?! Negative forward lookup, backward lookup does not match ? <! Negative backward lookup, backward lookup does not match Regular Expression Conditions: ? (Backreference) True-RegEx), where? This indicates that this is a condition. The backreference in parentheses is expressed by a number, representing the subexpression that will be executed only when the backreference exists. ? (Backreference) True-RegEx | false-RegEx) Common Regular Expressions: URL: HTTPS? : // [-\ W.] + (: \ D + )? (/([\ W/_.] *)? Complete URL: HTTPS? : // (\ W *: \ W *@)? [-\ W.] + (: \ D + )? (/([\ W/_.] * (\? \ S + )?)?)? Email Address: (\ W + \.) * \ W + @ (\ W + \.) + [A-Za-Z] +

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.