fork(1) download
  1. import re
  2. text = '''Mon-Thu, Sun 11:30 am - 9 pm'
  3. 'Sat-Sun 9:30 am - 9:30 pm'
  4. 'Sat 5 pm - 9 pm'''
  5. time_rx = r'\d?\d(?::\d\d)?\s*[ap]m'
  6. matches = re.findall(fr'\b{time_rx}\s*-\s*{time_rx}\b', text, re.I)
  7. for match in matches:
  8. print("".join(match.split()))
Success #stdin #stdout 0.03s 9436KB
stdin
Standard input is empty
stdout
11:30am-9pm
9:30am-9:30pm
5pm-9pm