import re
buffer = 'my_path: any_suffix'
share_path = '\\\\server\\final'
buffer = re.sub('my_path:.*', r'my_path: {}'.format(share_path.replace("\\", "\\\\")), buffer)
print(buffer)