Janilabo Posted May 22, 2012 Share Posted May 22, 2012 For trimming the end of a string. Example included.. TrimEnd [scar]function TrimEnd(str: string): string; var i, l: Integer; begin if (str = '') then Exit; l := Length(str); for i := l downto 1 do if (str <> ' ') then Break; Result := Copy(str, 1, i); end; var str: string; begin ClearDebug; str := ' TEST '; WriteLn('STR length before TrimEnd(): ' + IntToStr(Length(str)) + ' ("' + str + '").'); str := TrimEnd(str); WriteLn('STR length after TrimEnd(): ' + IntToStr(Length(str)) + ' ("' + str + '").'); end.[/scar] Quote Link to comment Share on other sites More sharing options...