An essay record of regular expressions under Python

Source: Internet
Author: User

An expression with the following regular is used:

Purpose: Remove the contents of the {} in the string

The last regular expression used is {(. *?)}

Look first . *? :

First of all. is used to match strings, but only once.

So add *, can let. is matched several times, but this will match until the last one is found,

Keep adding? , which indicates a non-greedy match, is to stop when. * matches to}. Then continue to match the next.

Look Again (. *?),

() means the grouping operation, the default is capture, that is, the grouped content can be taken out separately, by default each group has an index, starting from 1, according to the "(" Order of the index value.

In fact, after matching to the first {result}, the result is taken out.

Last look {(. *?)}:

A {} is used at the outermost perimeter, meaning that the data in {} is to be taken.

Regular and profound, and allow me to continue to study it!

An essay record of regular expressions under Python

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.