Find the last position of selected characters in a string SysUtils unit
 function LastDelimiter ( const Delimiters, Source : string ) : Integer;
The LastDelimiter function finds the last occurence of any of a set of Delimiter characters in a Source string.
If found, the position is returned. Otherwise, 0 is returned.
Strings start with 1 as the first character.
Related commands
AnsiPos Find the position of one string in another
StrScan Searches for a specific character in a constant string
 Author links

 Buy Website Traffic at

 Buy Proxies at
 Download this web site as a Windows program.

Example code : Find the last position of 1 or more characters in a string
  source, find : string;
  position     : Integer;

  // Create a string
  source := '12345678901234567890';

  // Find the position of the last 1
  position := LastDelimiter('1', source);
  ShowMessage('The last 1 is at '+IntToStr(position));

  // Find the position of the last 2, 4 or 6
  position := LastDelimiter('246', source);
  ShowMessage('The last 2, 4 or 6 is at '+IntToStr(position));
Show full unit code
   The last 1 is at 11
   The last 2, 4 or 6 is at 16
Delphi Programming Neil Moffatt 2002 - 2018. All rights reserved.  |  Home Page