Home  |  Delphi .net Home  |  System.String  |  TrimStart Method
  
TrimStart  
Method  
Trims specified characters from the start of a string
String Class
System NameSpace
CF1.  Function TrimStart ( CharArray : Array of Char ) : String;
CF : Methods with this mark are Compact Framework Compatible
Description
Removes selected leading characters from the current string.
 
It starts at the beginning of the string and keeps removing characters when they match one of the CharArray characters. It continues through the string removing characters until it encounters a character not in the array.
Notes
Like a lot of string methods, the string object itself is not affected - the modified string is returned for assignment.
Microsoft MSDN Links
System
System.String
 Author links

 Buy Website Traffic at
 Buywebsitetrafficexperts.com

 Buy Proxies at
 Buyproxies.io
 
 
 
A simple example
program Project1;
{$APPTYPE CONSOLE}

var
  strA, strB : String;
  charArray  : Array[0..1] of Char;

begin
  strA := '  --- Hello  --   ';
  charArray[0] := ' ';
  charArray[1] := '-';

  Console.WriteLine('strA = ''' + strA + '''');

  strB := strA.TrimStart(charArray);

  Console.WriteLine('Trimming '' '' and ''-'' chars from the start only');
  Console.WriteLine('strB = ''' + strB + '''');

  Console.ReadLine;
end.
   strA = '  --- Hello  --   '
   Trimming ' ' and '-' chars from the start only
   strB = 'Hello'  --   '
 
 
Delphi Programming Neil Moffatt 2002 - 2017. All rights reserved.  |  Contact the author