Move re.compile outside for loop