Python Challenge third-level solution http://www.pythonchallenge.com

Source: Internet
Author: User
Import res = ''. join (S. split () Fetch = Re. compile (R' [^ A-Z] [A-Z] {3} ([A-Z]) [A-Z] {3} [^ A-Z] '). findallprint ''. join (fetch (s ))

Result: Success list.

S is the third page source code in the comments part, the third page is: http://www.pythonchallenge.com/pc/def/equality.html

The key to solving this problem lies in the graphical information below the third-level image:

One small letter, surroundedExactlyThree big bodyguards on each of its sides.

There is a lower-case letter with three upper-case letters on both sides.

The key point of this sentence is the exactly expression. In fact, it means that the lowercase letter has only three uppercase letters on both sides, which is "only".

I think that my English is poor. At the beginning, I thought I was a little smart and thought that exactly was in uppercase or in bold. It was bigger than other words, so I naturally wrote the following regular expressions:

Fetch = Re. Compile (R' [exactly] {3} ([A-Z]) [exactly] {3} '). findall

But it is only found after running. It is wrong ,-_-

So I wrote an incorrect regular expression again.

Fetch = Re. Compile (R' [A-Z] {3} ([A-Z]) [A-Z] {3} '). findall

-_-What's going on? I didn't fully understand it. In fact, there should be only three upper-case letters on both sides of the lower-case letters, and there should be no more or less, so the correct regular expression should be:

Fetch = Re. Compile (R' [^ A-Z] [A-Z] {3} ([A-Z]) [A-Z] {3} [^ A-Z] '). findall

Very hurt ......

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.