ExcludeLeadingChar function
String / Filename routines
Return to Introduction  Previous page  Next page
Unit
acUtils  

Declaration
function ExcludeLeadingChar(St: String; Ch: Char): String;  

Description
The ExcludeLeadingChar function removes specified character from the beginning of a string if it's exists there. For example result of IncludeTrailingChar('\Software\Microsoft\CurrentVersion', '\') will be "Software\Microsoft\CurrentVersion". It's a typical function that gets rewritten by every programmer.  

Original code
function ExcludeLeadingChar(const St: String; Ch: Char): String;  
begin  
  Result := St;  
  while (Result <> ''and (Result[1] = Ch) do  
   Delete(Result, 11);   
end;