Regular matching replacement to remove weight is a little difficult to understand, solve

The

problem is as follows, as seen in the python getting started manual, re.sub () replaces
I know the syntax of re.sub (regular string, replacement string, original string), but I don"t understand this

clipboard.png

I also know that 1 is equivalent to re.search (). Group (1)
how does the above rule achieve the effect of removing weight?


(\ b [a-z] +) matches one word
(\ b [a-z] +)\ 1 matches two identical words with a space between them

Menu