Regular expression formula_ Learning regular friends are worth seeing


Too many introductions signed on the Internet are fierce essays, which can be understood while watching, but can’t help memory. Inspired by the five stroke radical table formula “look at the first three or two catties…”,
Try to write “regular expression mnemonic formula”, also known as “regular doggerel”, version 0.1, absolutely original, counterfeiting must be investigated,:)
Note: This article is only for the convenience of memory when learning regularization, and can not replace the systematic and comprehensive learning process. Please correct the mistakes and omissions!
In fact, regular is also snobbish, cutting his head to put money in;    (refers to the start symbol ^ and the end symbol $)
If you can’t recognize the special symbol, get a reverse bar to guide the way;    (means \  \* And other special symbols)
The back bar is followed by a small W,   Represented by numbers and letters;    (\ w followed by numbers and letters; \ D followed by numbers)
The reverse bar is followed by a small D,   Only numbers;
The reverse bar is followed by a small a,   Alarm symbol beeps;
The reverse bar is followed by a small B,   Word boundary or backspace;
The back bar is followed by a small t,   The tabulation symbols are clear;
The reverse bar is followed by a small R,   I know the enter symbol;
The reverse bar is followed by a small s,   Space symbols are important;
Lowercase and uppercase are really too much;
The reverse bar is followed by a big W,   Alphanumeric stand aside;
The reverse bar is followed by a big s,   Blank also stands aside;
The reverse bar is followed by a big D,   The number stands aside;
Inverted frame followed by big B,   Excluding the beginning and end;

A single character to repeat, three symbols to help;     (*  + ?)
0   Star plus 1   To infinity, the question mark is only 0   And 1;     (* table 0-n; + table 1-N;? Table 0-1 repeats)
Curly braces have more knowledge and strong ability of repeated operation;     ({n}   {n,}   {n,m})
To repeat a string, enclose it;     ((abc){3}   Indicates that the string “ABC” is repeated 3 times  )
Special collection customization, brackets to help you;    
Escape symbols don’t work. Queue up one by one;
There are too many rows. Please do me a favor;     ([1-5])
If the tip is put into square brackets, the antisense definition is powerful;     ([^ A] refers to any character except “a”  )
1. The vertical action is not small, and the two sides are regular and replace each other;      (the same key as “\” on the keyboard)
1. The vertical can be used many times, and the complex definition is very convenient;
Round brackets, multi-purpose;
Reverse reference the specified group, and the number typesetting character corresponds to it;     (“\ B (\ W +) \ B \ S + \ 1 \ B” refers to “(\ W +)”)
Support group name customization, with question marks and angle brackets;     (“(? < word > \ W +)” defines “\ W +” as a group, and the group name is “word”)
Round brackets are used for many purposes, and the position designation depends on it;
Question mark and equal sign string, positioned in front of the string;     (“\ B \ W + (? = ing \ b)” locate the string before “ing”)
To locate the string, insert a less than sign in the middle;     (“(? < = \ bsub) \ W + \ B” locate the string after “sub”)
Question mark plus exclamation mark followed by string;
PHPer knows,   ! It means to take the opposite;
Not followed by this string, all in line to report for duty;     (“\ w * D (?! OG) \ w *”, “dog” does not match, “do” matches)
The question mark is less than the exclamation mark, followed by a string;
Do not put this string in front, all in line to report for duty;    
The dot and asterisk are greedy. Adding a question mark is not greedy;
The plus sign and question mark are guaranteed, and they shall be repeated at least once;
Two question marks, the old rule, 0 times and 1 time;
Curly braces followed by a?, Greed becomes non greed;
There are still many that can’t fit, waiting to be added in the future.

Recommended Today

Java Engineer Interview Questions

The content covers: Java, mybatis, zookeeper, Dubbo, elasticsearch, memcached, redis, mysql, spring, spring boot, springcloud, rabbitmq, Kafka, Linux, etcMybatis interview questions1. What is mybatis?1. Mybatis is a semi ORM (object relational mapping) framework. It encapsulates JDBC internally. During development, you only need to pay attention to the SQL statement itself, and you don’t need to […]