Regular expressions¶
Regular expressions describe patterns in strings that can be used in order to determine whether a given pattern occurs in a text or not.
In TreeSize, regular expressions can be used to find specific files and / or folders that match the criteria specified by regular expressions. A list of special characters are supported.
The following table shows some of the most used syntax and provides a few examples:
Expression |
Syntax |
Description |
Example |
---|---|---|---|
Any character |
|
Matches any single character except a line break. |
|
Zero or more |
|
Matches zero or more occurrences of the preceding expression, and makes all possible matches. |
|
One or more |
|
Matches at least one occurrence of the preceding expression. |
|
Start of string |
|
Matches the start of a string. |
|
End of string |
|
Matches the end of a string. |
|
Beginning of word |
|
Matches only when a word starts at this point in the text. |
|
End of word |
|
Matches only when a word ends at this point in the text. |
|
Any one character in the set |
|
Matches any one of the characters in the []. To specify a range of characters, list the starting and ending characters separated by a dash (-), as in [a-z]. |
|
Any one character not in the set |
|
Matches any character that is not in the set of characters that follows the |
|
Or |
|
Matches either the expression before or the one after the OR symbol (|). Mostly used in a group. |
|
Escape character |
|
Matches the character that follows the backslash ( |
|
Repeat n times |
|
Matches n occurrences of the preceding expression. |
|
Grouping |
|
Lets you group a set of expressions together. If you want to search for two different expressions in a single search, you can use the Grouping expression to combine them. |
If you want to search for |
More examples¶
Regular Expression |
Use Case |
---|---|
|
Find all files/folders with at least one digit in its name. |
|
Find all files/folders containing “a” or “b” in their name. |
|
Find all files/folders containing at least one character in their name that is not in the range A-Z or a-z. |
|
Find all files/folders which start with an “E” followed by exactly 7 digits. |
|
Find all files/folders with a folder depth of at least 2 and at most 4. |
|
Find all files/folders with invalid ASCII characters. |
|
Find all files/folders with Unicode characters which cannot be printed. |
|
Find all file/folder names that contain the non-breakable space character (Unicode NOBR, U+00A0) instead of a normal space character. |
|
Find all file and folder names that contain characters which are invalid on SharePoint servers. |
|
Find all files and folders with a leading space. |
|
Find files with an extension that have a trailing space at the end of their name. |
|
Find folders with a trailing space at the end of their name. |
Tools for creating regular expressions¶
https://regex101.com/ (online)
http://regexpal.com/ (online)
http://sourceforge.net/projects/regexpeditor/ (download)
http://sourceforge.net/projects/regextester/ (download)
http://sourceforge.net/projects/regaxe/ (download)