Jump to content

[PASCAL] Trim function


CouldnoT
 Share

Recommended Posts

Trim function

 

This function is used to remove spaces from the start and the end of strings. If we have a string that contains the text ' Hello ' it will be 'Hello' after using this function. We can not display spaces in a terminal window unless we put characters between them. Look at the example below:

 

program TrimStr;
uses
 cthreads,
 Classes, SysUtil
var
 Line: string;
begin
 Line:= ' Hello ';
 Writeln('<', Line, '>');
 Line:= Trim(Line);
 Writeln('<', Line, '>');
 Readln;
end. 

 

In the foregoing example, we have used the unit SysUtils, which contains the Trim function.

There are another two functions that remove spaces from only one side of a string, before/after. These functions are: TrimRight, TrimLeft.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.