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 ......