HFS: File masks: Difference between revisions

From rejetto wiki
Jump to navigation Jump to search
Line 24: Line 24:
but also <i>a.jpg</i> , where the star has been replaced with nothing.
but also <i>a.jpg</i> , where the star has been replaced with nothing.


== The question point (?) ==
== The question mark (?) ==


stands for a <i>single character</i>. Something like <tt>A?B</tt> matches any 3 chars long filename,
stands for a <i>single character</i>. Something like <tt>A?B</tt> matches any 3 chars long filename,
starting with an A and ending with a B. The length is fixed to 3 characters because ? can be replaced by
starting with an A and ending with a B. The length is fixed to 3 characters because ? can be replaced by
only one single character. Thus the ? does not match the null string as the * does.
only one single character. Thus the ? does not match the null string as the * does.

Revision as of 18:32, 12 April 2006

What is it?

A file mask denotes a set of files. It is something like this: *.jpg;*.gif. This example denotes any jpeg and gif files.

How does it work?

The example above shows a double file mask. It has two atoms separated by the semicolon: *.jpg and *.gif. The semicolon is used to merge multiple masks: it is a special character. There are only 3 special characters in file masks: ; * and ?.

The star (*)

stands for any string of characters. If the mask contains only the star, it would match ANY file.

If you put an A before the star A*, it matches any file starting with an A.

If you put an A after the star *A, it matches any file ending with an A.

Moreover A*B matches any file starting with an A and ending with a B. In the example above, you find *.jpg : it matches any file ending with .jpg that is jpeg images. Well, know that jpeg files sometimes ends with .jpeg and rarely with .jpe .

The star matches also the null string: a*.jpg matches files like a1.jpg , adfgg.jpg but also a.jpg , where the star has been replaced with nothing.

The question mark (?)

stands for a single character. Something like A?B matches any 3 chars long filename, starting with an A and ending with a B. The length is fixed to 3 characters because ? can be replaced by only one single character. Thus the ? does not match the null string as the * does.