Files
renovate/docs/usage/string-pattern-matching.md
T
Jamie Tanna 128f446e08 docs: ensure that config in documentation is error and warning free (#43727)
* docs: skip validation on JSON files that aren't Renovate config

As part of future changes, we'll enable validation on all JSON code
snippets to run Config Validation.

Before we do that, we should opt-out JSON snippets that aren't anything
related to Renovate config.

* docs: don't validate invalid Renovate config

As it's intentionally referencing a manager that doesn't exist.

* docs: don't validate partial Renovate config

As part of future changes, we'll enable validation on all JSON code
snippets to run Config Validation.

There are several code snippets we have that are part of a Renovate JSON,
but it doesn't make sense to convert these to a fully passing config, as
it'd reduce clarity on what we're trying to explain.

* docs: convert `baseBranchPatterns` snippets to code blocks

So we can validate them.

* docs: make sure that `datasourceTemplate` is set

So this passes validation.

* docs: clarify that `force` is global config

As it may not be clear, so we can make it extra clear with a `.js` file,
and note that it's global self-hosted config.

* docs: make sure `packageRules` is an array

* docs: `matchBaseBranches` needs `baseBranchPatterns` to be set

* docs: correct typo for `prBodyColumns`

* docs: mark global config snippets as such

As part of future changes, we'll use this to detect whether it's global
self-hosted configuration.

* docs: make sure `packageRules` wraps its children

* docs: add `allowedHeaders`

* docs: ignore deprecation warnings

As part of future changes, we'll use this to note that we don't care
about the validation warnings.

* docs: make sure `customManagers` wraps its children

* docs: make sure `fleet` wraps its children

* docs: validate JSON snippets are valid Renovate config

To make sure that we're always presenting valid JSON configuration to
our users, we can validate them as part of `check-fenced-code`.

As well as configuration errors we can warn for warnings, but allow code
blocks to opt-out, for instance when there's a known deprecation
affecting the code block.

We need to make sure to set `allowedEnv` for various code snippets that
reference environment variables.

* docs(development): document fenced code block checks

* docs: wrap `configType` and `ignoreConfigWarnings` in `{ ... }`

As otherwise we see build failures i.e.

    WARNING -  Doc file 'modules/platform/gitlab/index.md' contains a link
       '../../../self-hosted-configuration.md#autodiscoverrepoorder', but the doc
       'self-hosted-configuration.md' does not contain an anchor '#autodiscoverrepoorder'.

This needs to be wrapped alongside all other options like `title`.

* fixup! docs: wrap `configType` and `ignoreConfigWarnings` in `{ ... }`
2026-06-02 13:29:48 +00:00

5.4 KiB

String Pattern Matching - Regex or Glob

Renovate string matching syntax for some configuration options allows you, as user, to choose between:

  • minimatch glob patterns, including exact strings matches
  • regular expression (regex) patterns

In cases where there are potentially multiple inputs, e.g. managers can have multiple categories, then the matcher will return true if any of them match.

Special case: Match everything

The value * is a special case which means "match everything". It is not valid to combine * with any other positive or negative match.

{
  "allowedEnv": ["*"]
}
{
  "allowedEnv": ["*", "ABC"]
}
{
  "allowedEnv": ["*", "!ABC"]
}

In the latter case, the * can be omitted and achieve the same thing.

Regex matching

A valid regex pattern:

  1. Starts with / or !/
  2. Ends with / or /i

Regex is case sensitive by default

By default, regex patterns are evaluated as case sensitive. To ignore case sensitivity you must set the i flag, see the regex patterns table for an example.

Renovate uses re2 syntax

Renovate uses the re2 library for regex matching. re2 is different from the full regex specification, because re2 has a different syntax/support.

For the full re2 syntax, read the re2 syntax wiki page.

Example regex patterns

Pattern Regex pattern explanation
/^abc/ matches any string starting with lower-case abc
/^abc/i matches any string starting with abc in lower or upper case, or a mix
!/^a/ matches any string not starting with a in lower case

Use regex101 to test your patterns

If you want to test your patterns interactively online, we recommend regex101.com. You can use the Code Generator in the sidebar and copy the regex in the generated "Alternative syntax" comment into JSON.

!!! warning "Escape the backslashes from regex101" Before you copy/paste the regex from regex101 into your Renovate config, you must escape the backslashes (\) first. For example: \n\s → \\n\\s.

Glob matching

If the string provided is not a regex pattern then it will be treated as a glob pattern and parsed using the minimatch library. Although glob patterns were designed originally for file name matching, many users find glob syntax easier to understand than regex so prefer it.

Glob patterns always ignore casing

Glob patterns are always evaluated with case insensitivity and you can not change this. If you need a case-sensitive pattern you must use a regex pattern.

Example glob patterns

Pattern Glob pattern explanation
abc123 matches abc123 exactly, or AbC123
abc* matches abc, abc123, ABCabc, but not abc/def
abc**/* matches abc/def but not abc, abcd, or abc/def/ghi,
abc**/** matches abc/def and abc/def/ghi, but not abc or abcd
abc{/,}** matches abc, abcd, abc/def, and abc/def/ghi

All matches above are case-insensitive, even if not shown.

Test your glob patterns

If you want to test your glob patterns interactively online, we recommend Digital Ocean's glob tool.

Negative matching

Renovate has a specific approach to negative matching strings.

"Positive" matches are patterns (in glob or regex) which do not start with !. "Negative" matches are patterns starting with !, like !/^a/ or !b*.

For an array of patterns to match, the following must be true:

  • If any positive matches are included, at least one must match
  • If any negative matches are included, none must match

For example, the pattern ["/^abc/", "!/^abcd/", "!/abce/"]:

  • matches "abc" and "abcf"
  • does not match "foo", "abcd", "abce", or "abcdef"

If you find yourself in a situation where you need to positive-match a string which starts with !, then you need to do so using a regular expression pattern. For example, ["/^!abc$/"] will positively match against the string "!abc".

One limitation of negative matching is when there may be multiple inputs to match against. For example, a manager may have multiple categories, such as java and docker. If you have a rule such as "matchCategories": ["!docker"] then this will return true because the java category satisfies this rule.

Usage in Renovate configuration options

Renovate has evolved its approach to string pattern matching over time, but this means that existing configurations may have a mix of approaches and not be entirely consistent with each other.

The configuration options that support "regex or glob" syntax mention this in their documentation, and also link to this page.