Wildcards - rejetto/hfs GitHub Wiki

Some settings support wildcards, like *.jpg

Special characters

  • * matches any number of characters, but not /. Eg: *.jpg
  • ? matches a single character, but not /. Eg: pic?.jpg matches pic1.jpg and pic2.jpg but not pic10.jpg
  • ** matches any number of characters, including /, as long as it's the only thing in a path part. Eg: **.jpg will match jpg-s also in subfolders.
  • ! at the beginning of a pattern will negate the match. Eg: !*.jpg will match any file that is NOT jpg.
  • | allow multiple values to be accepted (as an "or" expression). Eg: *.jpg|*.png will match both jpg and png

Please refer to specific documentation for a more comprehensive guide.

Escaping

If you need some special character literally, like (, you can preceed it with a \, like this: \(

Searching for files

When using the search button in the frontend, some extra rules apply:

  • if your text includes *, then the pattern is applied as it is
    • Eg: if you search *.jpg, then .jpg must be at the end of the name
    • Eg: if you search a*, you'll find all items starting with letter A (we are case-insensitive)
  • if your text doesn't include *, then it can be anywhere
    • Eg: if you search .jpg, .jpg is valid even if present in the middle of the name
    • this happens because * is automatically added at the start and end of your text
      • if | is used, then * is added at start+end of each part

Network masks

Network masks supports the syntax above, therefore you can use wildcards like this 192.168.0.*. If you want to exclude 192.168.0.5 from this, you can use this syntax 192.168.0.!(5).

Alternatively you can use a network syntax, supporting CIDR and ranges. The previous example is the same as doing 192.168.0.1/24, or also 192.168.0.1-192.168.0.255.

CIDR syntax and operators ! and | available from version 0.45, ip-ranges from version 0.48.

Tip: thanks to the negation operator ! you can turn the blacklist into a whitelist. Example: by blacklisting !192.168.*|10.*|127.0.0.1|::1 you are actually whitelisting local addresses. If you have multiple addresses to whitelist, have them all on a single line, joined by |.