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") )

