How To Use Glob Pattern In Paths?

Glob Pattern

Glob Pattern Overview

Glob patterns are widely used to match addresses in Unix-based systems. They utilize specific meta characters to define portions of an address. In addition to the basic wildcards, you can also use character classes and negation to refine your matching.

  • ? : Matches any single character.
  • * : Matches any sequence of characters (including an empty sequence).
  • [...] : Matches any one character enclosed in the brackets. You can specify ranges (e.g. [0-9]) and include specific characters like a hyphen (e.g. [abc-]). An unclosed bracket is considered invalid.
  • [...!] : Matches any character that is not listed within the brackets.
  • ** : Matches the current directory and all its subdirectories. This pattern must appear as a standalone path component (for example, **a or b** are invalid, and more than two consecutive asterisks are not permitted).

Important Notes

  • Glob patterns in VergeCloud are not case-sensitive.
  • When considering the common format of <scheme>://<hostname>/<path> for URLs, the pattern matches only the <hostname>/<path> part, ignoring the <scheme>.

Example: How Glob Patterns Match Paths

Glob Pattern Matches Does Not Match
*example.com
  • mail.example.com
  • blog.example.com
  • shop.example.com
  • a.example.com
  • test.mail.example.com (multiple subdomain parts allowed)
  • example.com (no subdomain)
  • example.net (different domain)
example.com/**
  • example.com/
  • example.com/path
  • example.com/path/subpath
  • sub.example.com/path (different subdomain)
  • example.net/path (different domain)
*.*.example.com
  • mail.us.example.com
  • www.eu.example.com
  • example.com (missing subdomains)
  • mail.example.com (only one subdomain)
  • api.dev.us.example.com (more than two subdomain parts)
api.*.example.com/v?
  • api.dev.example.com/v1
  • api.test.example.com/v2
  • api.example.com/v1 (missing intermediate subdomain)
  • api.dev.example.com/v (missing version digit)
  • api.dev.example.com/v10 (version has more than one character)
docs.??.example.com/**/guide[0-9].pdf
  • docs.us.example.com/guide1.pdf
  • docs.eu.example.com/docs/guide2.pdf
  • docs.uk.example.com/path/to/guide3.pdf
  • docs.u.example.com/guide1.pdf (only one character in subdomain)
  • docs.usa.example.com/guide1.pdf (three letters instead of two)
  • docs.eu.example.com/guide.pdf (missing version digit)
  • docs.eu.example.com/guide12.pdf (version contains two digits)
backup/[!0-9]*.zip
  • backup/archive.zip
  • backup/logs.zip
  • backup/1backup.zip (starts with a digit)
  • backup/9data.zip (starts with a digit)
*.txt
  • readme.txt
  • notes.txt
  • document.txt
  • image.jpg
  • archive.zip
  • README.TXT (if matching is case-sensitive)
file?.txt
  • file1.txt
  • fileA.txt
  • file10.txt (more than one character in place of '?')
  • file.txt (missing a character)
img[0-9].png
  • img0.png
  • img5.png
  • img9.png
  • img10.png (two-digit number)
  • imgA.png (letter, not a digit)
doc[!0-9].pdf
  • docA.pdf
  • doc_.pdf
  • doc1.pdf (digit in the specified position)
  • doc9.pdf
[*].log
  • *.log (literal filename "*.log")
  • Other filenames such as error.log or access.log
src/**/test/*.js
  • src/test/app.js
  • src/utils/test/helper.js
  • src/components/test/component.js
  • src/app.js (missing the "test" folder)
  • src/test/app.jsx (wrong file extension)
report-*-202[0-2].pdf
  • report-summary-2021.pdf
  • report-final-2020.pdf
  • report-2021.pdf (missing the dash-separated detail)
  • report-summary-2023.pdf (year outside the specified range)

Troubleshooting and Common Mistakes

  • Ensure every opening bracket [ has a matching closing bracket ]. An unclosed bracket will result in an error.
  • Use the ** wildcard as an independent path segment. Do not combine it with other characters (e.g., **a or b** are invalid).
  • Only one * or ** is allowed in a sequence; using more than two consecutive asterisks is not permitted.
  • The ? wildcard strictly matches a single character. Make sure the number of characters in your pattern aligns with your expectations.
  • When using negated character classes ([...!]), verify that the excluded characters are exactly those you intend to omit.
    • Related Articles

    • Using RE2 Regular Expressions

      Using RE2 Regular Expressions Introduction VergeCloud firewall rules support advanced filtering using RE2 regular expressions. These patterns help you match specific text — such as parts of URLs, headers, or query strings — to allow, block, or log ...
    • Understanding the Host Header

      The Host header is one of the most important elements in an HTTP request. It identifies the domain name that the client is trying to reach. When a browser sends a request to a server it includes the Host header so the server knows which website or ...
    • VergeCloud Error Codes

      While using VergeCloud services, you may occasionally encounter platform specific error codes. These errors are not random system failures. They usually indicate that a configured rule, security policy, or access restriction has been triggered. This ...
    • How to Test and Verify Rate Limiting in Your Application

      Rate limiting is a traffic control mechanism used to regulate the number of requests a client can make to a server within a defined time window. It plays a critical role in protecting web applications, APIs, and backend infrastructure from abuse, ...
    • Understanding VergeCloud’s DDoS Challenge Modes

      Distributed Denial of Service attacks are one of the most common threats faced by modern websites and online services. Attackers attempt to overwhelm servers with massive volumes of traffic or exploit application behavior to exhaust resources. If the ...