I have this list of links:
['/directory/index.html',
'/index.html',
'#',
'/index.html',
'/kss_how.html',
'dr_info/swearingenlarry.html',
'dr_info/swearingenlarrylast.html',
'dr_info/kingjohn.html',
'dr_info/kingjohnlast.html',
'dr_info/_coble.jpg',
'dr_info/coblebillielast.html',
'dr_info/netherystephen.jpg',
'dr_info/netherystephenlast.html',
'dr_info/rougeaupaul.jpg',
'dr_info/no_last_statement.html',
'dr_info/no_info_available.html',
'dr_info/no_last_statement.html',
'dr_info/no_last_statement.html']
which I need to select links like
'dr_info/kingjohn.html'
from and skip the rest.
So far I came up only with very inefficient solution:
p_1 = re.compile('dr.*(?<!last).html')
p_1_links = list(filter(p_1.match, links))
p_2 = re.compile('dr.*(?<!statement).html')
p_2_links = list(filter(p_2.match, p_1_links))
p_3 = re.compile('dr.*(?<!available).html')
valid_links = list(filter(p_3.match, p_2_links))
which makes me shiver and I hope some one can help me to fit it in one line.
Desired output from example would be like this:
['dr_info/swearingenlarry.html',
'dr_info/kingjohn.html']
Only links starting with dr_info
and ending with html
No links with last
, no_last_statement
or no_info_available