import re
text = """abc
123
def
356
more text..."""
print( re.findall(r"^123(?s:.*?)^3.*", text, re.M) )
# => ['123\ndef\n356']
print( re.findall(r"^123[\w\W]*?^3.*", text, re.M) )
# => ['123\ndef\n356']
aW1wb3J0IHJlCnRleHQgPSAiIiJhYmMKMTIzCmRlZgozNTYKbW9yZSB0ZXh0Li4uIiIiCnByaW50KCByZS5maW5kYWxsKHIiXjEyMyg/czouKj8pXjMuKiIsIHRleHQsIHJlLk0pICkKIyA9PiBbJzEyM1xuZGVmXG4zNTYnXQpwcmludCggcmUuZmluZGFsbChyIl4xMjNbXHdcV10qP14zLioiLCB0ZXh0LCByZS5NKSApCiMgPT4gWycxMjNcbmRlZlxuMzU2J10=