Appearance
MatchPattern
Declaration
Function MatchPattern( source, pattern : String) : Boolean
Example
pascal
procedure OnMapEvent(var Value:Variant);
begin
if MatchPattern('test.txt', '*.txt') then //returns true
LogInfo('The file is of type .txt');
if MatchPattern('c:\program files\test.txt', '*.txt') then //also returns true
LogInfo('The file is of type .txt');
end;Description
Returns True if the source string matches with the pattern. This matching function is intended for matching file paths and file names, and uses the wildcard characters defined for Windows file searches, i.e. * for zero or more matching characters, and ? for a match in the specified character position. The values for "source" and "pattern" should not exceed the maximum length for file names (255 characters).
For generic string matching and manipulation functions, not involving file names, see Flow Help section Scripting Reference, Functions, String .
More Examples
The following tests for matches will return True:
- MatchPattern('TEST.TXT', '*.txt')
- MatchPattern('test.txt', '*.TXT')
- MatchPattern('test.txt', '????.txt')
- MatchPattern('c:\program files\test.txt', 'c:\*\test.txt')
- MatchPattern('c:\program files\test.txt', 'c:\*\*.txt')
- MatchPattern('c:\program files\test.txt', 'c:\*.txt')
The following tests for matches will return False:
- MatchPattern('test.txt', '?.txt') // too many characters
- MatchPattern('t.txt', '????.txt') // not enough characters