s='start of text\n    line 1\n      line 2\n\nline 3\n  line 4\n\nstop matching after this\nline 5\n    line 6\n\nline 7'
res = []
stop = False  # Flag to know where to stop matching
for line in s.splitlines():
	if line.strip().startswith('stop matching after this'):
		stop = not stop  # Reverse the flag
	if stop:
		res.append(line) # Add line as is
	else:
		res.append(line.lstrip()) # Add the line stripped from the left

print("\n".join(res))