DelphiBasics
StrScan
Function
Searches for a specific character in a constant string SysUtils unit
 function StrScan(const Characters PAnsiChar; SearchChar Char):PAnsiChar;
Description
StrScan is used when you need to check a single character against a list of known characters (Characters).
 
If the SearchChar exists in Characters, then a pointer to the position in Characters is returned.
 
If it does not exist, a nil pointer is returned.
Related commands
AnsiPosFind the position of one string in another
AnsiIndexStrCompares a string with a list of strings - returns match index
AnsiMatchStrReturns true if a string exactly matches one of a list of strings
LastDelimiterFind the last position of selected characters in a string
 Download this web site as a Windows program.




 
Example code : A simple example
const
  Numbers = '0123456789';
begin
  if StrScan(Numbers, '2') <> nil
  then ShowMessage('2 is a numeric digit')
  else ShowMessage('2 is not a numeric digit');

  if StrScan(Numbers, 'A') <> nil
  then ShowMessage('A is a numeric digit')
  else ShowMessage('A is not a numeric digit');
end;
Show full unit code
  2 is a numeric digit
  A is not a numeric digit
 
Delphi Programming © Neil Moffatt . All rights reserved.  |  Home Page