I have a list of strings, below is just one example:
str_list = ['Navitas', 'Organic Cacao Powder', '227g', 'SALE $7.49 ea', 'Regular $9:99-ea', 'Valid 01/12 - 01/18']
I want to extract the '227g' element based on finding the index.
unit_index = [idx for idx, val in enumerate(str_list) if val.endswith((' ml','-pack','{\d}g', ' L'))]
But this doesn't seem to work. I would like to find out where it ends with a digit followed by a unit of measure (ml, g, L)
re.search(r'(?: ml|-pack|\d+g)$', val)? Or see ideone.com/L3xL1L