This function returns a new string with all trailing white-space characters removed.
NOTE The following characters are white-space characters: space (" "), tab ("\t"), carriage return ("\r"), newline ("\n"), form feed ("\f") and vertical tab ("\v"). See White-space Characters for the full list, including Unicode characters.
string_trim_end(str);
| Argument | Type | Description |
|---|---|---|
| str | String | The string to trim |
var _the_string = "A\nB\n\C\nD\n\n\n\n\n\n";
var _clean_string = string_trim_end(_the_string);
The above code first defines a string with many newlines at the end and stores it in a temporary variable _the_string. It then calls string_trim_end to remove all the newline characters at the end of the string (but not the ones between the letters) and stores the result in another temporary variable _clean_string.