import re
text = """"
\nword1 meanings
\nword123 measings
\nword12345 meanings
"""
maxLen = len(max(re.findall(r"^\S+", text, re.M), key=len))
result = re.sub(r"(\S+)[^\S\r\n]+", lambda m: '{{:{}s}}'
.format(str(maxLen + 1))
.format(m.group(1)),
text)
print(result)
aW1wb3J0IHJlCgp0ZXh0ID0gIiIiIgpcbndvcmQxICAgICBtZWFuaW5ncwpcbndvcmQxMjMgICAgICAgICBtZWFzaW5ncwpcbndvcmQxMjM0NSAgICAgICAgbWVhbmluZ3MKIiIiCgptYXhMZW4gPSBsZW4obWF4KHJlLmZpbmRhbGwociJeXFMrIiwgdGV4dCwgcmUuTSksIGtleT1sZW4pKQpyZXN1bHQgPSByZS5zdWIociIoXFMrKVteXFNcclxuXSsiLCBsYW1iZGEgbTogJ3t7Ont9c319JwogICAgICAgICAgICAgICAgLmZvcm1hdChzdHIobWF4TGVuICsgMSkpCiAgICAgICAgICAgICAgICAuZm9ybWF0KG0uZ3JvdXAoMSkpLAogICAgICAgICAgICAgICAgdGV4dCkKcHJpbnQocmVzdWx0KQ==