JavaScript

$u.s.rTrim Function

Syntax

$u.s.rTrim(str as string [, chr as string])

Arguments

str string

The string that has extra whitespace to remove from the end.

chrstring

(Optional) Specifies the characters to remove from the string.

Description

Trim the right of a string, removing spaces and any passed in characters.

Example

var string1 = 'this is a string with trailing spaces      ';
string1 = $u.s.rTrim(string1);
/*resulting string is 'this is a string with trailing  spaces'*/

var string1 = '    -   this string has a leading and trailing  dash and spaces   -    ';
string1 = $u.s.rTrim(string1,' -');
/*the resulting string is '    -   this string has a leading and  trailing dash and spaces'. The trailing spaces and - have been removed.*/