My goto here would be to use a regular expression to match lines with the formatting you want. You can ignore, store, or otherwise flag the lines that don't match.
import re text_in = """9/5/21, 8:07 PM - Me: Lol romantic comedy https://music.youtube.com/ 2006 present 9/5/21, 8:38 PM - Friend: Yup """ datetime_rx = re.compile(r"(\d\d?/\d\d?/\d\d, \d\d?:\d\d [AP]M) - (.*)") for line in text_in.splitlines(): match = datetime_rx.match(line) if match: print(f"Found timestamp: {match.groups()[0]}, Contents: {match.groups()[1]}") else: print(f"no timestamp: {line}")