import re
regex = re.compile(r"(\d+)\.\s\"([a-zA-Z ]+)\"\s[a-zA-Z \.]+\s([a-zA-Z, \.]+)\s([\d:]+)", flags=re.MULTILINE)
test_str = ("1. \"Anbae Anbae\" Vairamuthu Hariharan, K. S. Chitra 5:10\n"
"2. \"I Love You\" Vairamuthu Nandini Srikar, KK, Ajith Kumar 4:55\n"
"3. \"Nathi Enge Valaiyum\" Vairamuthu Ghanshyam Vaswani 4:37\n"
"4. \"Nothing Nothing\" Vairamuthu Harini 4:44\n"
"5. \"Poovukellam Siragu\" Vairamuthu Srinivas, KK, Harini 5:27\n"
"6. \"Vannakili SolKonda\" Vairamuthu Gopal Rao, Harini, Chorus 4:38")
subst = "\\1 \\2 - \\3 \\4"
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