Janilabo Posted May 22, 2012 Share Posted May 22, 2012 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] Quote Link to comment Share on other sites More sharing options...