System.Masks.MatchesMask

From RAD Studio API Documentation
Jump to: navigation, search

Delphi

function MatchesMask(const Filename, Mask: string): Boolean;

C++

extern DELPHI_PACKAGE bool __fastcall MatchesMask(const System::UnicodeString Filename, const System::UnicodeString Mask);

Properties

Type Visibility Source Unit Parent
function public
System.Masks.pas
System.Masks.hpp
System.Masks System.Masks

Description

Indicates whether a file name conforms to the format specified by a filter string.

Call MatchesMask to check the Filename parameter using the Mask parameter to describe valid values. A valid mask consists of literal characters, sets, and wildcards.

Each literal character must match a single character in the string. The comparison to literal characters is case-insensitive.

Each set begins with an opening bracket ([) and ends with a closing bracket (]). Between the brackets are the elements of the set. Each element is a literal character or a range. Ranges are specified by an initial value, a dash (-), and a final value. Do not use spaces or commas to separate the elements of the set. A set must match a single character in the string. The character matches the set if it is the same as one of the literal characters in the set, or if it is in one of the ranges in the set. A character is in a range if it matches the initial value, the final value, or falls between the two values. All comparisons are case-insensitive. If the first character after the opening bracket of a set is an exclamation point (!), then the set matches any character that is not in the set.

Wildcards are asterisks (*) or question marks (?). An asterisk matches any number of characters. A question mark matches a single arbitrary character.

MatchesMask returns true if the string matches the mask. MatchesMask returns false if the string does not match the mask. MatchesMask raises an exception if the mask is syntactically invalid.

Note: The Filename parameter does not need to be a file name. MatchesMask can be used to check strings against any syntactically correct mask.

See Also

Code Examples