I am attempting to write a regex in Python to extract part of a paragraph.
In the below paragraph, the part I wish to extract is bolded.
Proposal will boost bailout fund, inject cash into banks and cut
Greek debt says reports.
My regex and output as follows,
>>> text = 'Proposal will boost bailout fund, inject cash into banks and cut Greek debt says reports.'
>>> pattern = re.compile(r'(boost bailout)+?([\s\S]*?)(debt)+?')
>>> print re.findall(pattern, text)
[('boost bailout', ' fund, inject cash into banks and cut Greek ', 'debt')]
Although it does extract the correct section, is it right that the extraction is separated into 3 parts in a tuple and not just a single line such as the below?
[('boost bailout fund, inject cash into banks and cut Greek debt')]
From the documentation:
If you want one match, do: