Bemærk
Adgang til denne side kræver godkendelse. Du kan prøve at logge på eller ændre mapper.
Adgang til denne side kræver godkendelse. Du kan prøve at ændre mapper.
The LASTSUBSTRINGBEFORE function returns the substring before the last occurrence of a delimiter.
An Azure Cosmos DB system function that splits a string at the last delimiter and returns the prefix portion.
Syntax
LASTSUBSTRINGBEFORE(<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 last delimiter
In this example, the LASTSUBSTRINGBEFORE function returns the portion before the last / character.
SELECT VALUE {
parentPath: LASTSUBSTRINGBEFORE("/products/shoes/boots", "/"),
prefix: LASTSUBSTRINGBEFORE("A-B-C", "-")
}
[
{
"parentPath": "/products/shoes",
"prefix": "A-B"
}
]
Get the text before the last string delimiter
In this example, the LASTSUBSTRINGBEFORE function returns the portion before the last :: delimiter.
SELECT VALUE {
hierarchy: LASTSUBSTRINGBEFORE("bike::touring::frame", "::")
}
[
{
"hierarchy": "bike::touring"
}
]
Remarks
- This function doesn't use the index.