I am trying to extract text between two words including the words that set the boundary using findall().
description = 'White cat sat on the mat and then the cat ran away'
starting_word = 'cat'
ending_word = 'ran'
detail_re = r'{0}.*?{1}'.format(starting_word, ending_word)
extracted_text_list = re.findall(detail_re, description,re.IGNORECASE)
Expected result:
['cat sat on the mat and then the cat ran', 'cat ran']
However, the result is:
['cat sat on the mat and then the cat ran']
How can I get the expected answer?