length
Description
Returns the number of characters in a string.
Syntax
Like many functions in DataPrime, length supports two notations, function and method. These interchangeable forms allow flexibility in how you structure expressions.
- Function notation
- Method notation
length(value: string): number
(value: string).length(): number
Arguments
| Name | Type | Required | Description |
|---|---|---|---|
value | string | true | The string to measure |
Example
Count the number of characters in a string
Consider the following document:
{
"str_val": "such logs, much tracing, wow!"
}
Use length to count the number of characters:
Example query
- Function notation
- Method notation
create str_val_len from length(str_val)
create str_val_len from str_val.length()
Example output
{
"str_val": "such logs, much tracing, wow!",
"str_val_len": 29
}