How to achieve left alignment of the following text? Thanks in advance!
text = """"
\nword1 meanings
\nword123 measings
\nword12345 meanings
"""
expected:
text = """"
\nword1 meanings
\nword123 measings
\nword12345 meanings
"""
I have tried to use re.sub then using ljust, but it does not work.
In [58]: print(re.sub('(\n[\w]+\s*)', r'\1'.ljust(20), text))
"
word1 meanings
word123 measings
word12345 meanings
# or print(re.sub('(\n[\w]+\s*)', r'\1'+' '*(20-len(r'\1')), text))
# the result is same