Perl Study Notes No. 7

Source: Internet
Author: User

Regular Expressions in Perl

1. It is a wildcard and can match any single character, except for line breaks. If you want to use. In the mode, use /.

2. * match the first item zero or multiple times, such as/AB * C/match AC, ABC, abbbbbc...

3. + can match the previous item once or any number of times, such as/AB + C/, matching ABC, abbc, abbbbc...

4 .? This indicates that the previous item appears once or does not appear, for example,/AB? C/, matching ABC, or AC

5. () is used for grouping, such as/(AB) + C/, matching ABC, ababc, abababc; or/(AB) * C/, matching any string ending with C

6. | indicates matching the left or right, that is, if the Left is not matched, the right is matched, for example,/AB | C/, matching AB or C

7. [] can match any single character in the brackets, such as [ABC], matching a, B, c

8.-The font size can be used in []. For example, [a-c] is the same as the preceding example.

9. ^ used in [] to obtain the complement, for example, [^ d-Z], matching [ABC]

10. Any numeric class, [0-9], can be abbreviated as:/d

11./W is called "word" character: [A-Za-z0-9 _]

12./s indicates [/f/n/T/R]. "In fact, it is rare to use/s separately without using any quantifiers (*, + )"

13. /d,/W,/s, will match the characters corresponding to them in lower-case form that cannot match, equivalent to [^/d], [^/W], [^/S]

14. [/D/d] is usually used to match any character

 

 

 

 

 

 

 

 

Related Article

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.