SysUtilsStrScan (Delphi)

From RAD Studio Code Examples
Jump to: navigation, search

Description

The following example uses a button on a form. When the button is clicked, the text is searched for a wildcard (asterisk character).

Code

function HasWildcards(FileName: PChar): Boolean;
{ Return True if the file name has wildcards in it. }
begin
  HasWildcards := (StrScan(FileName, '*') <> nil) or
    (StrScan(FileName, '?') <> nil);
end;

procedure TForm1.Button1Click(Sender: TObject);
const
  P: PChar = 'C:\Test.* ';
begin
  if HasWildcards(P) then
    ShowMessage('The string has wildcards')
  else
    ShowMessage('The string does not have wildcards');
end;

Uses