SoFunction
Updated on 2025-03-04

Regular Expression Meditations_Friends who learn regularity are worth a look

Too many introductions signed online are all fierce short articles. You can read and understand them while reading, but it can’t help memorize them. Inspired by the Wubi font root formula "Look at the head for three or two jin..."
Try to write "regular expression mnemonic formula" also known as "regular limerick", version 0.1, absolutely original, imitation will be prosecuted, :)
Note: This article is only for the purpose of learning rules for the convenience of memory, and cannot replace the systematic and comprehensive learning process. Please correct any mistakes and omissions!
Regularly, it is actually snobbish, sharpen the head to put the money; (refers to the start symbol ^ and the end symbol $)
If you can't recognize the special symbols, you can make a backlash to lead the way;  (refers to special symbols such as \. \*)
The backward bar is followed by a small w, and the number letters are represented; (\w and number letters;\d and number)
The back bar is followed by a small d, and only numbers are used to represent it;
The back bar is followed by a small a, and the alarm symbol beeps;
The backward bar is followed by a small b, and the word boundary or backspace is demarcated;
The back bar is followed by a small t, and the tab symbol is very clear;
The back bar is followed by a small r, and the carriage return symbol is known;
The back bar is followed by a small s, and the space symbol is very important;
Lower case and back case and capital case are so numerous;
The back bar is followed by a large W, and the alphanumeric numbers stand aside;
The backward bar is followed by the big S, and the blank space is just aside;
The back bar is followed by the big D, and the number will stand aside from now on;
The inverted box is followed by a large B, excluding the beginning and end;

A single character needs to be repeated, three symbols will help;   (* +?)
0 stars plus 1 to infinity, and the question marks only focus on 0  and 1;   (*Table 0-n; +Table 1-n;?Table 0-1 repetition)
There is a lot of knowledge in curly braces and strong ability to repeat operations;   ({n} {n,} {n,m})
To repeat a string, enclose it; ((abc){3} means that the string "abc" is repeated 3 times)
Special collection customization, brackets are used to help you;
Escape symbols don't work, they come to queue up one by one;
There are so many things that I can’t get enough to line up. Please come and help me;   ([1-5])
Put the pointed end in brackets, the anti-sense definition is powerful; ([^a] refers to any character except "a")
1 The vertical function can be quite large, and the two sides are replaced regularly; (The keyboard is the same key as "\")
1 Vertical can be used many times, and it is very convenient to define complexly;
Garden brackets, many uses;
Reverse reference to the specified group, the number lineup corresponds to it; (The number "1" in "\b(\w+)\b\s+\1\b" refers to the previous "(\w+)")
Support group name customization, question mark plus angle brackets; ("("("("("Word>\w+"" is defined as a group, and the group name is "Word")
Garden brackets have many uses, and the location is all up to it;
Question mark equal sign string, positioning before the string;   ("\b\w+(?=ing\b)" locates the string before "ing")
To locate the string behind, insert a smaller than sign in the middle; ("("(?<=\bsub)\w+\b" locate the string behind "sub")
A question mark plus an exclamation mark followed by a string;
PHPer knows it,  ! It means to reverse;
If this string is not followed, all of them will be reported; ("\w*d(?!og)\w*", "dog" does not meet, "do" meets)
The question mark is smaller than the exclamation mark, followed by a string;
There is no string in front of you, and all of them are in line with each other to report;
The dot asterisk is very greedy, and adding a question mark is not greedy;
The plus question mark is guaranteed, and it will be repeated at least once;
Two question marks are the old rules, 0 times and 1 time;
Braces followed by? , greed becomes non-greed;
There are still many things that cannot be accommodated, waiting for the increase in the future.