Unit 'sysutils' Package
[Overview][Constants][Types][Classes][Procedures and functions][Variables][Index] [#rtl]

Trim

Trim whitespace from the ends of a string.

Declaration

Source position: sysstrh.inc line 107

function Trim(

  const S: ansistring

):ansistring;

function Trim(

  const S: WideString

):WideString;

function Trim(

  const S: UnicodeString

):UnicodeString;

Description

Trim strips blank characters (spaces and control characters) at the beginning and end of S and returns the resulting string. All characters with ordinal values less than or equal to 32 (a space) are stripped.

If the string contains only spaces, an empty string is returned.

Errors

None.

See also

TrimLeft

  

Trim whitespace from the beginning of a string.

TrimRight

  

Trim whitespace from the end of a string.

Example

Program Example84;

{ This program demonstrates the Trim function }

Uses sysutils;
{$H+}

Procedure Testit (S : String);

begin
  Writeln ('"',Trim(S),'"');
end;

Begin
  Testit ('  ha ha what gets lost ? ');
  Testit (#10#13'haha ');
  Testit ('              ');
End.

Documentation generated on: Oct 27 2024