import re
regex = re.compile(r"(,\d{3}$)", flags=re.MULTILINE)
test_str = ("1\n"
"00:00:06,000 --> 00:00:12,074\n"
"- = www.OpenSubtitles.org = -\n\n"
"2\n"
"00:01:35,623 --> 00:01:38,208\n"
"Apollo Três aqui.\n"
"Houston, você pode me copiar?\n\n"
"3\n"
"00:01:39,168 --> 00:01:41,378\n"
"Apollo Três, aqui é Houston.\n"
"Voce me ouve\n\n"
"4\n"
"00:01:41,503 --> 00:01:43,797\n"
"Bem recebido, de Houston.\n"
"Apollo Três aqui.\n\n"
"5\n"
"00:01:44,340 --> 00:01:48,385\n"
"Apollo Três, está tudo bem aqui.\n\n"
"6\n"
"00:01:49,428 --> 00:01:52,973\n"
"- Lee, você pode me copiar?\n"
"- Você é recebido, Capcom. Que falador.")
subst = "$1\\n<font color=#FFFF00>"
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