Module pd3f.string_utils

Functions

def strip_spaces_line_end(text)
Expand source code
def strip_spaces_line_end(text):
    """Removing spaces at the end of a line.

    For instance in this string `the text  \n` the space is removed.
    While `the text\n` the string is unchanged.
    """
    if len(text) < 2:
        return text
    if text[-1] == "\n" and text[-2] == " ":
        return strip_spaces_line_end(text[:-2]) + "\n"
    return text

Removing spaces at the end of a line.

For instance in this string `the text

the space is removed. Whilethe text ` the string is unchanged.