The filematch function

Description

The filematch function accepts two parameters as described below, and returns a value of type boolean, which indicates whether the filename matches the file specification. If the filename matches the file specification then the value true is returned, and if the filename does not match the file specification then the value false is returned.

Parameter

  1. The first parameter (file-spec) is an expression of type string or type char, which contains the file specification with which the filename is being matched. The file specification may contain the following wildcard characters('*' and '?'). The character '*' if used in the file specification matches any zero or more characters in the filename. The character '?' if used in the file specification matches any single character in the filename.
  2. The second parameter (filename) is an expression of type string or type char, which contains the filename to be matched with the file specification. The filename is not tested for validity nor does the file have to exist.

Example

   filematch('file.txt', 'file.txt')  returns  true
   filematch('file.txt', 'otherfile.txt')  returns  false
   filematch('*.txt', 'file.txt')  returns  true
   filematch('*.txt', 'otherfile.txt')  returns  true
   filematch('a?c', 'abc')  returns true
   filematch('a?c', 'agc')  returns true
   filematch('a?c', 'azc')  returns true
   filematch('a?', 'abc')  returns false
   filematch('a?c', 'ab')  returns false
   filematch('?c', 'bc')  returns false
   filematch('??c', 'abc')  returns true
   filematch('a??', 'avd')  returns true

Portability

Operating Systems: All
Standard Pascal: No