Remove characters from the beginning or/and end

Syntax

s.ltrim([char|chars])
s.rtrim([char|chars])
s.trim([char|chars])

 

Parameters

s - str variable.

char - character to remove. Integer character code. Default: space and other white characters.

chars - set of characters to remove. String.

 

Remarks

ltrim removes the specified characters from the beginning of s.

rtrim removes the specified characters from the end of s.

trim removes the specified characters from the beginning and end of s.

 

In Unicode mode, don't use non ASCII characters as char or in chars.

 

Example

str s = " String "
s.trim
 now s is "string"
s.trim('g')
 now s is "strin"
s.trim("stn")
 now s is "Stri"