# 0907.py import re u=re.compile('...$',re.M) testo='prima\nseconda\nterza' ris=u.search(testo) if ris: print (ris.group()) # ima