Regular Expressions: Difference between revisions
("None of the following" Excludes files matching the regex from the file list, not the other way around.) |
|||
(24 intermediate revisions by 16 users not shown) | |||
Line 1: | Line 1: | ||
Regular expressions are used in [[Filename_Filters|filename filters]] as a way to filter files on either the client or server side. | |||
The flavor of regular expressions used are [http://en.wikipedia.org/wiki/Regular_expression#POSIX_Extended_Regular_Expressions POSIX extended regular expressions]. | |||
Note that by selecting "None of the following" as a [[Filename_Filters|file filter criteria type]], you can effectively select those files that ''do not'' match the specified criteria. | |||
= Regular Expressions Match Anywhere In The Name = | |||
Unless anchored to the beginning or the end of the file name, they will match if they occur anywhere inside the file name. See the '^' and '$' characters. | |||
Thus, if your regular expression is 'x', then any filename that contains the letter x anywhere will match (beginning, middle, or end). | |||
= All Non-Special Characters = | |||
All characters not specified below will match exactly in the filename. Thus, the regular expression 'foo' will match "foobar", "barfoo", and "quxfoobaz". | |||
= The '.' Character = | |||
The '.' character matches any single character. Thus, 'd.t' matches both "dat" and "dot". | |||
= The '*' Character = | |||
The '*' character matches 0 or more of the preceding token. Thus, 'foo.*bar' matches both "fooquxbar" and "foobar". The regular expression 'ge*k' matches "gk", "gek", "geek", and "geeeeeeeeeeeeeeeek". | |||
= The '?' Character = | |||
The '?' character matches 0 or 1 of the preceding token. Thus, 'gee?k' matches "gek" and "geek", but not "gk" or "geeek". | |||
= The '^' Character = | |||
The '^' character matches the beginning of the filename. So, '^x' matches all file whose names begin with the letter 'x'. | |||
= The '$' Character = | |||
The '$' character matches the end of the filename. Thus, 'x$' matches all files whose names end with the letter 'x'. | |||
= The '\' Character = | |||
This character escapes the following token, so that it does not take on special meaning. For example, if you wanted to filter for files that begin with a period, then the regular expression '^\.' would accomplish that for you. If you had just specified '^.', you would have matched all files that began with any single character. |
Latest revision as of 06:18, 8 July 2020
Regular expressions are used in filename filters as a way to filter files on either the client or server side.
The flavor of regular expressions used are POSIX extended regular expressions.
Note that by selecting "None of the following" as a file filter criteria type, you can effectively select those files that do not match the specified criteria.
Regular Expressions Match Anywhere In The Name[edit]
Unless anchored to the beginning or the end of the file name, they will match if they occur anywhere inside the file name. See the '^' and '$' characters.
Thus, if your regular expression is 'x', then any filename that contains the letter x anywhere will match (beginning, middle, or end).
All Non-Special Characters[edit]
All characters not specified below will match exactly in the filename. Thus, the regular expression 'foo' will match "foobar", "barfoo", and "quxfoobaz".
The '.' Character[edit]
The '.' character matches any single character. Thus, 'd.t' matches both "dat" and "dot".
The '*' Character[edit]
The '*' character matches 0 or more of the preceding token. Thus, 'foo.*bar' matches both "fooquxbar" and "foobar". The regular expression 'ge*k' matches "gk", "gek", "geek", and "geeeeeeeeeeeeeeeek".
The '?' Character[edit]
The '?' character matches 0 or 1 of the preceding token. Thus, 'gee?k' matches "gek" and "geek", but not "gk" or "geeek".
The '^' Character[edit]
The '^' character matches the beginning of the filename. So, '^x' matches all file whose names begin with the letter 'x'.
The '$' Character[edit]
The '$' character matches the end of the filename. Thus, 'x$' matches all files whose names end with the letter 'x'.
The '\' Character[edit]
This character escapes the following token, so that it does not take on special meaning. For example, if you wanted to filter for files that begin with a period, then the regular expression '^\.' would accomplish that for you. If you had just specified '^.', you would have matched all files that began with any single character.