rstrip
rstrip is a string processing operation found in several programming languages that removes characters from the right end of a string. The name stands for right-strip, referring to the direction of removal. The behavior is most commonly associated with removing trailing whitespace, but languages often allow a custom set of characters to be removed as well.
In its default form, rstrip removes trailing whitespace characters such as spaces, tabs, and newlines. When
Return value and mutability vary by language. In languages with immutable strings (such as Python), rstrip returns
Examples illustrate common usage: "hello world ".rstrip() yields "hello world"; "path/to/file.txt\n".rstrip() yields "path/to/file.txt". When a character
See also lstrip (left-strip) and strip (both sides). Rstrip is frequently used to clean input, remove line