Regular Expression cheats

Source: Internet
Author: User
Regular Expressions are the bastion hosts that every programmer can't go around. They only need to attack it. I think regular expressions are difficult. The first difficulty is memory, and the second difficulty is Abstract Logic Thinking.
Too many introductions on the Internet are a tough short article. You can understand it while reading it, but it doesn't help you remember it. Inspired by the five-stroke root table,
Try "Regular Expression help note", also known as "Regular Expression oil poem", version 0.1, absolutely original, counterfeit must be studied ,:)
Note: This article is intended only for the convenience of memory when learning regular expressions. It cannot replace the full learning process of the system. please correct me if you have any mistakes!
In fact, regular expressions are also Snoop, And you can sharpen your head to carry your money. (It refers to the starting symbol ^ and the ending symbol $)
Special symbols cannot be recognized. You can use inverted bars to lead the road. (special symbols such)
Backward bars are represented by W, numbers, and letters (/W, numbers, and letters;/d, and numbers)
Backward bars are followed by small D, which is only represented by numbers;
The reverse bar is followed by a, and an alarm symbol is opened;
Backward bars are followed by Small B, and the word is split or unsigned;
The inverted bar is followed by a small t, and the tabulation symbol is clear;
The reverse bar is followed by a small R. The carriage return symbol is displayed;
The inverted bars are followed by small S. The space symbol is very important;
The lower-case password and upper-case password are too many;
The back of the upbar is followed by a large number of characters and numbers;
The reverse bars are followed by the big S, and the blank space is on the edge;
Backward bars are followed by Big D, and numbers are now on the edge;
The inverted box is followed by a large B, excluding the start and end;

A single character must be repeated. Three symbols are used for help. (* + ?)
0 stars plus 1 to infinity, the question mark is only 0 and 1; (* Table 0-n; + Table 1-N ;? Table 0-1 repetition)
You can learn more in curly brackets and have strong repeated operations. ({n} {n ,}{ n, m })
To repeat the string, enclose the string. (ABC) {3} indicates that the string "ABC" is repeated three times)
Special set customization, brackets to help you;
Escape characters do not work, so they are queued one by one;
There are so many issues to be unable to cope with. Please help me on the horizontal bar. ([1-5])
Parentheses ([^ A] indicates any character except ")
1. The vertical function is not small, and the two sides are replaced by regular expressions. ("/" is the same key on the keyboard)
1. portrait can be used many times, and complicated definition is very convenient;
Garden brackets for multiple purposes;
References a specified group in reverse order, and the number delimiter corresponds to it. ("/B (/W +) the number "1" in/B/S +/1/B references the previous "(/W + )")
Custom group names are supported. question marks are added with Angle brackets. ("(? <Word>/W +) "defines"/W + "as a group named" word ")
Square brackets are used for multiple purposes, and all positions are specified based on it;
The equal sign of the question mark (?) to locate the front of the string. ("/B/W + (? = Ing/B) "locate the string before" ing)
To locate the end of the string, insert a smaller sign in the middle; ("(? <=/Bsub)/W +/B "to locate the string after" sub)
Add an exclamation point to the question mark, followed by a string;
All phper knows ,! It indicates the inverse;
If it is not followed by this string, it will all comply with the Report; ("/W * D (?! OG)/W * "," dog "does not match, and" do "Does)
The question mark is less than the exclamation point, followed by a string;
If this string is not included in the previous section, it will all comply with the report;
The asterisk (*) is greedy and a question mark (*) is not greedy;
The plus sign has a guaranteed-performance question mark, which must be repeated at least once;
There are two question marks in the old rule, one round for 0 times;
Followed by curly braces ?, Greedy becomes not greedy;
There are still a lot of installation failures, waiting to be added later.

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.