zjfz-2019-s393639/regexp/Task302.py

15 lines
255 B
Python
Raw Permalink Normal View History

2020-01-25 11:09:37 +01:00
#!/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 '<NONE>'
else:
return out.group(2)