I wrote the following code to match a pattern but I can't get it.import re
pattern = re.compile(r"(\w+) (\w+)")
match = pattern.findall("Hello Chelsea Hello ManU")
print(match)
Out:[('Hello', 'Chelsea'), ('Hello', 'ManU')] What I try to achieve is.
[('Hello', 'Chelsea') , ('Chelsea', 'Hello') , ('Hello', 'ManU') ]
pattern = re.compile(r"(\w+) (\w+)")
match = pattern.findall("Hello Chelsea Hello")
print(match)
Out:[('Hello', 'Chelsea')]
What I try to achieve is.
[('Hello', 'Chelsea') , ('Chelsea', 'Hello') ]
Why regex ignore the two words if match found for a later search? How to achieve that output. Thank you.