In [1]:
import os
import glob
import re

In [2]:
def remove_glob_re(pattern, pathname, recursive=True):
    for p in glob.glob(pathname, recursive=recursive):
        if os.path.isfile(p) and re.search(pattern, p):
            os.remove(p)

In [3]:
remove_glob_re('\d+.txt', 'temp/**')