ltrim() / rtrim()

Purpose

ltrim

ltrim(str)

Removes any spaces at the start of a given string. Input is a string, output is the same string starting with the first non-space character.

rtrim

rtrim(str)

Removes any spaces at the end of a given string. Input is a string, output is the same string ending with the last non-space character.

Example

ltrim

In the following example the spaces at the beginning of the string are removed.

ltrim("   str ")

produces

"str "

rtrim

In the following example the spaces at the end of the string are removed.

rtrim("   str ")

produces

"   str"

Support: rsyslog Assistant | GitHub Discussions | GitHub Issues: rsyslog source project

Contributing: Source & docs: rsyslog source project

© 2008–2025 Rainer Gerhards and others. Licensed under the Apache License 2.0.