I am trying to fetch the particular format of the string from the content up to first occurrence of 5 digits. For example:
s = """ Regular expressions are a powerful language
for matching text patterns.
This page gives a basic introduction
to regular expressions 56122 sufficient
for our Python exercises and shows
how regular expressions 65842 work 23 in Python."""
print(re.findall(r"matching .* ? \d{5}", s, re.DOTALL))
However, I'm getting the following output:
['matching text patterns.
This page gives a basic introduction
to regular expressions 56122 sufficient
for our Python exercises and shows
how regular expressions 65842']
I would like this instead:
['matching text patterns.
This page gives a basic introduction
to regular expressions 56122']