[Solved] find hex value in list using regular expression


Try this:

import re

lst = ['a', '4', 'add', 'e', 'a', 'c0a8d202', '128', '4', '0', '32']
pattern = re.compile(r'c[0-9a-fA-F]?')

for i in lst:
    if re.search(pattern, i):
        print(lst.index(i))

Note:
this is as per your desired output but i am agree with @Jean-François Fabre who said that what’s wrong with lst.index(‘c0a8d202’) ? what’s the point of regular expressions here when you have the value already?

2

solved find hex value in list using regular expression