- import re 
- foo = "this is IMP Y text\nand this is also IMP1 Y text\nthis is not so IMP2 N text\nY is not important" 
- print(re.findall(r'\w+(?=[^\S\r\n]+Y\b)', foo)) 
				aW1wb3J0IHJlCmZvbyA9ICJ0aGlzIGlzIElNUCBZIHRleHRcbmFuZCB0aGlzIGlzIGFsc28gSU1QMSBZIHRleHRcbnRoaXMgaXMgbm90IHNvIElNUDIgTiB0ZXh0XG5ZIGlzIG5vdCBpbXBvcnRhbnQiCnByaW50KHJlLmZpbmRhbGwocidcdysoPz1bXlxTXHJcbl0rWVxiKScsIGZvbykp