import re
# Adding anchors:
print( re.sub("^.*$", "(replacement)", "sample text") )
# Using the count=1 argument
print( re.sub(".*", "(replacement)", "sample text", count=1) )
# If you want to replace non-empty lines:
print( re.sub(".+", "(replacement)", "sample text") )
aW1wb3J0IHJlCiMgQWRkaW5nIGFuY2hvcnM6CnByaW50KCByZS5zdWIoIl4uKiQiLCAiKHJlcGxhY2VtZW50KSIsICJzYW1wbGUgdGV4dCIpICkKIyBVc2luZyB0aGUgY291bnQ9MSBhcmd1bWVudApwcmludCggcmUuc3ViKCIuKiIsICIocmVwbGFjZW1lbnQpIiwgInNhbXBsZSB0ZXh0IiwgY291bnQ9MSkgKQojIElmIHlvdSB3YW50IHRvIHJlcGxhY2Ugbm9uLWVtcHR5IGxpbmVzOgpwcmludCggcmUuc3ViKCIuKyIsICIocmVwbGFjZW1lbnQpIiwgInNhbXBsZSB0ZXh0IikgKQoK