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

The SUBSTRINGAFTER function returns the substring after the first occurrence of a delimiter.

An Azure Cosmos DB system function that splits a string at the first delimiter and returns the suffix portion.

Syntax

SUBSTRINGAFTER(<string_expr_1>, <string_expr_2>)

Arguments

Description
string_expr_1 A string expression to search.
string_expr_2 A string expression that specifies the delimiter.

Return types

Returns a string expression.

Examples

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

Get the text after the first delimiter

In this example, the SUBSTRINGAFTER function returns the portion after the first | character.

SELECT VALUE {
  suffix: SUBSTRINGAFTER("contoso|north|2026", "|"),
  remainder: SUBSTRINGAFTER("a/b/c", "/")
}
[
  {
    "suffix": "north|2026",
    "remainder": "b/c"
  }
]

Get the text after a string delimiter

In this example, the SUBSTRINGAFTER function returns the portion after the first :: delimiter.

SELECT VALUE {
  details: SUBSTRINGAFTER("bike::touring::frame", "::")
}
[
  {
    "details": "touring::frame"
  }
]

Remarks

  • This function doesn't use the index.