Why it capture only "word", but not all the string | SoloLearn: Learn to code for FREE!

+1

Why it capture only "word", but not all the string

import re pattern = r"(.+) \1" match = re.match(pattern, "word word") if match: print ("Match 1") In Powershell the pattern above will capture all the string, because metasymbol ". " is captures anym symbol, so the match. groups() should be "word word", but not "word"

4/17/2018 1:54:28 PM

Pavel Kandratsyeu

4 Answers

New Answer

+1

Because the space is in the pattern. I understand you searching all characters on the left of a space. The result is "world".

0

There is a space in you pattern. What's append if you remove it?

0

So, this is the question, why it doesn't captute space...

0

I didn't see the space.... Thank you very much for the help.