date_regs = [r'(\d{4})-(\d{2})-(\d{2})',r'(\d{2})-(\d{2})-(\d{4})'] for reg in date_regs: match = re.match(reg,search_query) if match!=None: day = match.groups[0]