Han shunping: Regular Expression exercise questions

Source: Internet
Author: User
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) $/

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.