fork download
  1. import re
  2. time = r'(?:1[0-2]|0?[1-9])(?::(?:[0-5][0-9]))?\s?[ap]m'
  3. pattern = re.compile(r'(?i)(?<!\d){0}\s*-\s*{0}\b'.format(time))
  4. texts = ['Lorem Ipsum is dummy text of the printing and typesetting industry between 2am-8pm.',
  5. 'Contrary to popular belief, Lorem Ipsum is not simply random text.',
  6. 'Lorem has been the industry between 2:00am - 8:00pm standard dummy text since the 1500s.',
  7. 'It has survived not only five centuries, but also between 08:00am-05:00pm',
  8. 'It was popularised from 5:30am - 8:59pm with the release of Letraset sheets.',
  9. 'More recently with desktop publishing software like Aldus PageMaker 983-765-0976.']
  10. for text in texts:
  11. print (text, bool(pattern.search(text)), sep=" : ")
Success #stdin #stdout 0.02s 9516KB
stdin
Standard input is empty
stdout
Lorem Ipsum is dummy text of the printing and typesetting industry between 2am-8pm. : True
Contrary to popular belief, Lorem Ipsum is not simply random text. : False
Lorem has been the industry between 2:00am - 8:00pm standard dummy text since the 1500s. : True
It has survived not only five centuries, but also between 08:00am-05:00pm : True
It was popularised from 5:30am - 8:59pm with the release of Letraset sheets. : True
More recently with desktop publishing software like Aldus PageMaker 983-765-0976. : False