import re
string = '...\n[TestErrorMsg]./index[/TestErrorMsg]\n[TestErrorMsg]./index[/TestErrorMsg]\n[TestErrorMsg]./index[/TestErrorMsg]\n456\nsddsfgsd: [WinError] 32432532\n[TestErrorMsg]./index[/TestErrorMsg]\n'
print(re.compile('\[[A-Za-z]+].*?\[/[A-Za-z]+][\r\n]').sub('', string))