Muistiinpano
Tämän sivun käyttö edellyttää valtuutusta. Voit yrittää kirjautua sisään tai vaihtaa hakemistoa.
Tämän sivun käyttö edellyttää valtuutusta. Voit yrittää vaihtaa hakemistoa.
The SUBSTRINGBEFORE function returns the substring before the first occurrence of a delimiter.
An Azure Cosmos DB system function that splits a string at the first delimiter and returns the prefix portion.
Syntax
SUBSTRINGBEFORE(<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 before the first delimiter
In this example, the SUBSTRINGBEFORE function returns the portion before the first | character.
SELECT VALUE {
prefix: SUBSTRINGBEFORE("contoso|north|2026", "|"),
firstSegment: SUBSTRINGBEFORE("a/b/c", "/")
}
[
{
"prefix": "contoso",
"firstSegment": "a"
}
]
Get the text before a string delimiter
In this example, the SUBSTRINGBEFORE function returns the portion before the first :: delimiter.
SELECT VALUE {
category: SUBSTRINGBEFORE("bike::touring::frame", "::")
}
[
{
"category": "bike"
}
]
Remarks
- This function doesn't use the index.