rstrip¶
The rstrip filter is designed to remove trailing whitespace characters from the end of a string.
Functionality
- Strings: Takes a string as input.
- Stripping: Removes any whitespace characters (spaces, tabs, newlines) from the end of the string.
- Output: Returns a new string with the trailing whitespace removed.
Syntax
ArgumentsThe rstrip filter does not require any arguments.
Code Samples
Example 1: Removing Trailing Spaces
Output:
Example 2: Removing Trailing Tabs and NewlinesOutput:
Outliers and Special Cases¶
- Empty Strings: If the input string is empty, the
rstripfilter returns an empty string. - Strings Without Trailing Whitespace: If the input string does not have any trailing whitespace, the filter returns the original string unchanged.
- Non-String Input: If the input is not a string, the
rstripfilter might attempt to convert it to a string or return an error, depending on how Experience Builder handles type conversions.
Key Points¶
- The
rstripfilter is a handy tool for cleaning and normalizing string data. - It is particularly useful when dealing with user input or data imported from external sources where trailing whitespace might be present.
- Combine it with
lstripto remove both leading and trailing whitespace, or withstripto remove whitespace from both ends in a single operation.