The basis of regular expressions (i)

Source: Internet
Author: User

Zhang Xiaoxiang Regular expression Video learning notes.

1. What is a regular expression

Regular expressions are translated by the English phrase "regular expression", which can be understood as a language that blurs the text.

Using some special characters (meta-characters) to express text should have some characteristics.

2. Definition of meta-characters

A character with a special meaning in a regular expression that describes the character of the text.

For example, "?" Indicates that the preceding characters are optional, such as ABC? The description character "C" is optional and can match ABC and AB.

3. Sub-match

The portion of the regular expression enclosed in parentheses is called a sub-match, and the sub-match can also be referenced again.

The \1 can match the first sub-match, and \2 can match the second sub-match.

For example, 2 consecutive arbitrary numbers can be represented by (\d) \1, and any 5 consecutive digits can be matched with (\d) \1{4}.

1221,3553 can use (\d) (\d) \2\1 to represent a matching relationship.

The basis of regular expressions (i)

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.