lstrip¶
The lstrip filter is designed to remove leading whitespace characters from the beginning of a string.
Functionality
- Strings: Takes a string as input.
- Stripping: Removes any whitespace characters (spaces, tabs, newlines) from the start of the string.
- Output: Returns a new string with the leading whitespace removed.
Syntax
Arguments
The lstrip filter does not require any arguments.
Code Samples
Example 1: Removing Leading Spaces
Output: Example 2: Removing Leading Tabs and NewlinesOutput:
Outliers and Special Cases¶
- Empty Strings: If the input string is empty, the
lstripfilter returns an empty string. - Strings Without Leading Whitespace: If the input string does not have any leading whitespace, the filter returns the original string unchanged.
- Non-String Input: If the input is not a string, the
lstripfilter might attempt to convert it to a string or return an error, depending on how Experience Builder handles type conversions.
Key Points¶
- The
lstripfilter 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 leading whitespace might be present.
- Combine it with
rstripto remove both leading and trailing whitespace, or withstripto remove whitespace from both ends in a single operation.