import re
regex = re.compile(r"@[^@]+/.*\n", flags=re.MULTILINE)
test_str = ("Y:\\TH2020-0600_1P00392G01_02\\1P00392G01_02.obc[30-SEP-20 10:42:47\n\n"
"@30-SEP-20 10:42:51\n"
"yhjubad7\n"
"q28ed7qai\n"
"aiuwdh8\n"
"\"30-SEP-20 10:43:06\n"
"@30-SEP-20 10:43:39\n"
"nkdjaw\n"
"adibw\n"
"akwudbnawikd\n"
"/30-SEP-20 10:43:52\n"
"@30-SEP-20 10:43:52\n"
"ahuwsd8\n"
"2dhaiubd\n"
"98wha98\n"
"\"30-SEP-20 10:49:39\n\n"
"]30-SEP-20 11:29:03\n"
"Y:\\TH2020-0600_1P00392G01_02\\1P00392G01_02.obc[01-OCT-20 11:19:08\n"
"]01-OCT-20 11:26:29")
subst = ""
result = regex.sub(subst, test_str)
if result:
print(result)
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for Python, please visit: https://docs.python.org/3/library/re.html