The following are the expressions used by Han shunzheng to exercise questions. I hope to help students of php Chinese network!
The following is an expression Exercise by Han shun Zheng, hoping to help students in the first PHP community!
Question 1: understanding of m in the matching option gim, ^ (\ d) u $
2 Aaaddddjkkkkku
4 ddddkkiieu
Effect of ^ in Multi-section mode on positioning at the beginning and end
Question 2: Give the matching result:
/(\ D) {4}/gi match AAA1234kkkk
/1 {3}/1111 111 appears several times 111 2 times
/1 {3, 4}/1111 111 appears several times 1111,111 note greedy match once 1111 once 111
/1 +/1111 111 the result is a greedy match of 1111 111
/1 */1111 111 the result is 11111111 at a time
/1? /The result of null character match is successful.
The/a1 */a111111 result is a111111. Note that * is modified by 1.
[Abc] abcd matches a, B, c, d in sequence.
/(Han | inclusive)/select a match character
Question 3: Construct a regular expression () of a rule called a subexpression.
Abba (\ d) \ 2 \ 1 Note \ 1 is not (\ d) Learn to capture subexpressions and reverse reference subexpressions
For example, aabbccdd (\ d) \ 1 (\ d) \ 2 (\ d) \ 3 (\ d) \ 4
The first five digits are any number-339911 (\ d) {5}-(\ d) \ 2 (\ d) \ 3 (\ d) \ 4
Comprehensive: email format
1. Only one @
2. @ the front is the user name, can be 0-9 a-z A-Z _ character
3. @ is followed by a domain name, which can be sohu.com or tsinghua.org.cn and can only contain English letters.
/^ [A-zA-Z0-9 _-] + @ ([a-zA-Z0-9 _-] + \.) + (com | cn | net | org) $/