import re

regex = r"^([^;]+);[\r\n]*([^;]+);[\r\n]*([^;]+);"

test_str = ("New York City; Iron Man; no superpowers;\n"
	"Metropolis; Superman; superpowers;\n"
	"New York City;\n"
	"Spider-Man;\n"
	"superpowers;\n"
	"Gotham; Batman; no superpowers;\n"
	"New York City; Doctor Strange; superpowers;\n\n")

subst = "\\1;\\2;\\3;"

# You can manually specify the number of replacements by changing the 4th argument
result = re.sub(regex, subst, test_str, 0, re.MULTILINE | re.DOTALL)

if result:
    print (result)