Dec-05-2018, 02:49 PM
import re timestamp = re.compile(r'\d{2}:\d{2} ') # <- the white space is a part of the timestamp text = '''So from 12:23 that very moment you actually 12:25 actually continued the form of a choice, 12:28 that you kept going to the point of 12:30 no return, where you actually became who 12:33 you are now. 12:35 So you actually took part in 12:38 who you are now.''' filtered_text = timestamp.sub('', text) print(filtered_text)Problem: 99:99 is also a valid match.
A better pattern:
timestamp = r'[012][0123456789]:[012345][0123456789] ' timestamp = r'[0-2]\d:[0-5]\d ' # short formBut this also allows values in timestamps like 25:00, which is an invalid time.
You can check each timestamp, if it's valid and if, then removing it.
The question is, do you need that?
Almost dead, but too lazy to die: https://sourceserver.info
All humans together. We don't need politicians!
All humans together. We don't need politicians!