Jump to content
Janilabo

TrimBegin

Recommended Posts

For trimming the beginning of a string (removes empty spaces). Example included.

 

TrimBegin

[scar]function TrimBegin(str: string): string;

var

i, l: Integer;

begin

if (str = '') then

Exit;

l := Length(str);

for i := 1 to l do

if (str <> ' ') then

Break;

Result := Copy(str, i, ((l + 1) - i));

end;

 

var

str: string;

 

begin

ClearDebug;

str := ' TEST ';

WriteLn('STR length before TrimBegin(): ' + IntToStr(Length(str)) + ' ("' + str + '").');

str := TrimBegin(str);

WriteLn('STR length after TrimBegin(): ' + IntToStr(Length(str)) + ' ("' + str + '").');

end.[/scar]

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
  • Create New...