fork download
  1. import re
  2.  
  3. text = """"
  4. \nword1 meanings
  5. \nword123 measings
  6. \nword12345 meanings
  7. """
  8.  
  9. maxLen = len(max(re.findall(r"^\S+", text, re.M), key=len))
  10. result = re.sub(r"(\S+)[^\S\r\n]+", lambda m: '{{:{}s}}'
  11. .format(str(maxLen + 1))
  12. .format(m.group(1)),
  13. text)
  14. print(result)
Success #stdin #stdout 0.03s 9480KB
stdin
Standard input is empty
stdout
"

word1     meanings

word123   measings

word12345 meanings