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
AnsiPos Find the position of one string in another
AnsiIndexStr Compares a string with a list of strings - returns match index
AnsiMatchStr Returns true if a string exactly matches one of a list of strings
LastDelimiter Find the last position of selected characters in a string
 Author links

 Buy Website Traffic at
 Buywebsitetrafficexperts.com

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




 
Example code : A simple example
// Full Unit code.
// -----------------------------------------------------------
// You must store this code in a unit called Unit1 with a form
// called Form1 that has an OnCreate event called FormCreate.
 
unit Unit1;
 
interface
 
uses
  SysUtils,   // Unit containing the StrScan command
  Forms, Dialogs;
 
type
  TForm1 = class(TForm)
    procedure FormCreate(Sender: TObject);
  end;
 
var
  
Form1: TForm1;
 
implementation
{$R *.dfm} // Include form definitions
 
procedure TForm1.FormCreate(Sender: TObject);

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;
 
end.
Hide full unit code
   2 is a numeric digit
   A is not a numeric digit
 
Delphi Programming Neil Moffatt 2002 - 2017. All rights reserved.  |  Home Page