I have a list of urls that I would like to parse:
['https://www.richmondfed.org/-/media/richmondfedorg/press_room/speeches/president_jeff_lacker/2017/pdf/lacker_speech_20170303.pdf','http://www.federalreserve.gov/newsevents/speech/powell20160929a.htm','http://www.federalreserve.gov/newsevents/speech/fischer20161005a.htm']
I would like to use a Regex expression to create a new list containing the numbers at the end of the string and any letters before punctuation (some strings contain numbers in two positions, as the first string in the list above shows). So the new list would look like:
['20170303', '20160929a', '20161005a']
This is what I've tried with no luck:
code = re.search(r'?[0-9a-z]*', urls)
Update:
Running -
[re.search(r'(\d+)\D+$', url).group(1) for url in urls]
I get the following error -
AttributeError: 'NoneType' object has no attribute 'group'
Also, it doesn't seem like this will pick up a letter after the numbers if a letter is there..!