I have a mail log file, which is like this:
Aug 15 00:01:06 **** sm-mta*** to=<user1@gmail.com>,<user2@yahoo.com>,user3@aol.com, some_more_stuff
Aug 16 13:16:09 **** sendmail*** to=<user4@yahoo.com>, some_more_stuff
Aug 17 11:14:48 **** sm-mta*** to=<user5@gmail.com>,<user6@gmail.com>, some_more_stuff
What I want is a list of all mail hosts in lines that contain "sm-mta". In this case that would be: ['gmail.com', 'yahoo.com', 'aol.com', 'gmail.com', gmail.com']
re.findall(r'sm-mta.*to=.+?@(.*?)[>, ]') will return only first host of each matching line (['gmail.com','gmail.com'])
re.findall(r'.+?@(.*?)[>, ]') will return the correct list, but I need filtering too. Is there any workaround on this?