Say I have a text file with the line 'I like elephants'. If I cat the said file and the pipe it to 'grep elephants', I get the entire line "I like elephants".
How do I achieve this functionality in Python with re? Ive been trying the following:
test = re.search('elephants', 'I like elephants.\nThey are nice')
test.group(0)
I get only the word 'elephants' and not the whole sentence as the output.
How do I get the entire sentence? Thank you.