MatchesMask (Delphi)

From RAD Studio Code Examples
Jump to: navigation, search

Description

This example requires an edit box and a button on a form. When you click the button, the text inserted into the edit box is checked against some particular file name mask and then a corresponding message is displayed. The mask and an example of a string that matches it are also displayed on the form.

Code

procedure TForm1.Button1Click(Sender: TObject);
begin
  if MatchesMask(Edit1.Text, '[a-z][0-9]?[0-9]*.??[0-9]') then
    ShowMessage('File name is OK.')
  else
    ShowMessage('Invalid file name.');
end;

Uses