본문 바로가기

Dev/python

[python] python searching string within list

import re

li = ['df  1','as  3']

regex=re.compile("(df).*")

for l in li:
    for m in [regex.search(l)]:
        if m:
            print(m.group(0))