REGEXREPLACEALL - Query language in Cosmos DB (in Azure and Fabric)

The REGEXREPLACEALL function returns a string where all regular expression matches are replaced.

An Azure Cosmos DB system function that performs a regular expression replacement for all matches.

Syntax

REGEXREPLACEALL(<subject>, <pattern>, <replacement>, [<options>])

Arguments

Description
subject The string to search.
pattern The regular expression pattern to match.
replacement The string that replaces all matches.
options Optional. A string of regular expression flags: i (ignore case), m (multiline), s (singleline or dotall), and x (ignore pattern whitespace).

Return types

Returns a string expression.

Examples

This section contains examples of how to use this query language construct.

Replace all regular expression matches

In this example, the REGEXREPLACEALL function replaces every numeric sequence.

SELECT VALUE {
  replaceAll: REGEXREPLACEALL("A12-B34-C56", "[0-9]+", "#")
}
[
  {
    "replaceAll": "A#-B#-C#"
  }
]

Remarks

  • This function doesn't use the index.