import re from sys import stdin my_re = re.compile(r'^([0-9]{4}-[0-9]{2}-[0-9]{2,}|\d+|N(?:aN|one)|)((?!\n)\D.*|)$') for line in stdin: m = my_re.match(line) if m: print(m.groups())
2020-10-2125Chavez and Sons 2020-05-02Bean Inc NaNRobinson, Mcmahon and Atkins 2020-04-25Hill-Fisher 2020-04-02Nothing and Sons 52457Carpenter and Sons 0Carpenter and Sons Carpenter and Sons NoneEconomy and Sons 2020-04-02
('2020-10-2125', 'Chavez and Sons')
('2020-05-02', 'Bean Inc')
('NaN', 'Robinson, Mcmahon and Atkins')
('2020-04-25', 'Hill-Fisher')
('2020-04-02', 'Nothing and Sons')
('52457', 'Carpenter and Sons')
('0', 'Carpenter and Sons')
('', 'Carpenter and Sons')
('None', 'Economy and Sons')
('2020-04-02', '')