#!/usr/bin/python # -*- coding: utf-8 -*- import re def extract_minutes(string): pattern = r'^([\d]|1[\d]|2[0-3]):([0-5][\d])$' out = re.search(pattern, string) if out is None: return '' else: return out.group(2)