---
title: "String expressions"
description: "Aerospike string expression operations for filters, operate projections, and secondary-index filter expressions."
---

# String expressions

> For the complete documentation index see: [llms.txt](https://aerospike.com/docs/llms.txt)
> 
> All documentation pages available in markdown.

This page describes string expressions that run the same Unicode-aware logic as [string Operate API operations](https://aerospike.com/docs/develop/data-types/string/operations), inside an [expression](https://aerospike.com/docs/develop/expressions/) tree rather than against a named bin.

Read expressions such as `string_contains` and `string_strlen` evaluate to an integer, boolean, or string. That makes them **projection**: they shape what a command returns for each record, in [`operate`](https://aerospike.com/docs/develop/learn/bin-operations/), in a [batch](https://aerospike.com/docs/develop/learn/batch/), and in a [query](https://aerospike.com/docs/develop/learn/queries/projection). Wrap one in [comparison](https://aerospike.com/docs/develop/expressions/comparison) or [logic](https://aerospike.com/docs/develop/expressions/logic) to get the Boolean a record filter needs. They are also accepted as secondary-index filter expressions.

Comparison operators (`eq`, `ne`, `gt`, `ge`, `lt`, `le`) are not Unicode-aware: they order String values by UTF-8 bytes. `string_contains` can match a spelling that `eq` rejects. See [Compare String values](https://aerospike.com/docs/develop/data-types/string/comparison).

String expressions that read stored data can evaluate to `unknown`; see [Unknown results](https://aerospike.com/docs/develop/expressions#unknown-results). Invalid UTF-8 in the stored value is an additional cause specific to String.

Invalid UTF-8 behaves differently across the two surfaces: through `operate` a malformed bin returns `AS_ERR_INVALID_ENCODING`, while in a filter expression it evaluates to `unknown` and the record is silently excluded from results. See [String operations and UTF-8 validation](https://aerospike.com/docs/database/advanced/special-upgrades/820-upgrade#string-operations-and-utf-8-validation).

A string operand is a bin, read with [`bin_str`](https://aerospike.com/docs/develop/expressions/storage#bin_str), or any expression that evaluates to a string.

## When to use expressions versus Operate API

[Operations and expressions](https://aerospike.com/docs/develop/learn/operations-and-expressions/) covers the general split: an operation changes what is stored, while an expression produces a value to filter on, project, or store. Two cases are particular to String.

For worked examples, see [string examples](https://aerospike.com/docs/develop/data-types/string/examples).

### Modify expressions return a value

[String modify operations](https://aerospike.com/docs/develop/data-types/string/operations#modifying-strings) write the bin and return nothing. Every modify operation grouped under [Modify](#modify) below instead evaluates to the transformed string without writing it back. Use them to project or compare a normalized value, and use the Operate API when you need to persist the change.

### Reaching a String nested in a List or Map

Use a context path on the [String Operate API](https://aerospike.com/docs/develop/data-types/string/operations), or compose string expressions with [list](https://aerospike.com/docs/develop/expressions/list) or [map](https://aerospike.com/docs/develop/expressions/map) expressions. See [Strings nested in a List or Map](#strings-nested-in-a-list-or-map) below for a worked example.

### Naming differences from AEL text

Every Operate API string operation has an expression form, but a few are spelled differently in AEL text than in the client builders, and a few have no AEL function at all:

-   **`insert`** is `splice` in AEL, which disambiguates it from the list and map `insert` functions. The client helpers keep the `insert` name.
-   **`byte_length`** is `bytesLength` in AEL. The client helpers keep the `byte_length` name.
-   **`to_double`** is `toFloat` and **`to_integer`** is `toInt` in AEL, which names them after the AEL type rather than the client one. Pin the receiver before either, as in `$.rate:STRING.toFloat()`, so the compiler parses the string rather than casting a number.
-   **`append`, `prepend`, `concat`** have no AEL function. AEL concatenates with the type-directed `+` operator. The client helpers expose [`string_append`](#string_append), [`string_prepend`](#string_prepend), and [`string_concat`](#string_concat) for consistency with the Operate API.
-   **`regex_compare`** has no AEL function either. AEL matches with the infix `=~` operator and a regex literal, written `expr =~ /pattern/flags`. The client helpers expose [`string_regex_compare`](#string_regex_compare).

`regexReplace` replaces only the first match unless the pattern carries the `g` flag, written `/pattern/g`. The client helpers replace all matches when passed the `GLOBAL` regex flag. AEL writes flags as letters on the regex literal rather than as a bit field, and takes a subset of the flags the builders do — see [Regex flags](https://aerospike.com/docs/develop/data-types/string/regex-syntax#flags) for the mapping and for which are valid where.

These names apply to AEL text. For AEL syntax, see the [AEL reference](https://aerospike.com/docs/develop/client/sdk/concepts/ael/reference).

### Migration from cmp\_regex

Prefer [`string_regex_compare`](#string_regex_compare) over legacy [`cmp_regex`](https://aerospike.com/docs/develop/expressions/comparison#cmp_regex). The legacy form uses POSIX regex and is not Unicode-compatible.

### Strings nested in a List or Map

Nest a string expression inside a [list](https://aerospike.com/docs/develop/expressions/list) or [map](https://aerospike.com/docs/develop/expressions/map) expression to reach a String inside a CDT. The collection expression projects the value, and the string expression transforms it.

The [Operate API](https://aerospike.com/docs/develop/data-types/string/operations#context) reaches the same values through a context path and writes the result back in place. Use expressions when the result feeds a filter, when several operations compose into one value, or for `expression_read` projections.

This reaches `vehicles[0].make` in the sample data from [Working with nested collection data types](https://aerospike.com/docs/develop/expressions/nesting) and uppercases it, so evaluating it against that record yields `"TOYOTA"`.

The two SDKs take [AEL](https://aerospike.com/docs/develop/client/sdk/concepts/ael/reference) text, where the path does the navigating: `select_from()` and `selectFrom()` document it as their primary input. The other clients compose the same thing from builders — the list getter projects the Map, the map getter projects the String, and the string expression transforms it. Rust can also compile AEL, with [`from_ael`](https://aerospike.com/docs/develop/client/sdk/concepts/ael/reference), but its read operation takes a built expression.

-   [Java SDK](#tab-panel-2344)
-   [Python SDK](#tab-panel-2345)
-   [Rust](#tab-panel-2346)
-   [C#](#tab-panel-2347)
-   [Go](#tab-panel-2348)
-   [Node.js](#tab-panel-2349)
-   [C](#tab-panel-2350)
-   [Java](#tab-panel-2351)
-   [Python](#tab-panel-2352)

```java
// AEL text, which selectFrom() and where() take directly.

String exp = "($.vehicles.[0].make:STRING).upper()";
```

```python
# AEL text, which select_from() and where() take directly.

exp = "($.vehicles.[0].make:STRING).upper()"
```

```rust
use aerospike::expressions::{int_val, list_bin, string as str_exp, string_val, ExpType};

use aerospike::expressions::{lists as list_exp, maps as map_exp};

use aerospike::operations::string::{StringPolicy};

use aerospike::{ListReturnType, MapReturnType};

let make = map_exp::get_by_key(

    MapReturnType::Value, ExpType::STRING, string_val("make".to_string()),

    list_exp::get_by_index(

        ListReturnType::Values, ExpType::MAP, int_val(0),

        list_bin("vehicles".to_string()), &[]),

    &[]);

let exp = str_exp::upper(&StringPolicy::default(), make);
```

```csharp
using Aerospike.Client;

Exp make = MapExp.GetByKey(MapReturnType.VALUE, Exp.Type.STRING, Exp.Val("make"),

  ListExp.GetByIndex(ListReturnType.VALUE, Exp.Type.MAP, Exp.Val(0),

    Exp.ListBin("vehicles")));

Expression exp = Exp.Build(StringExp.Upper(StringPolicy.Default, make));
```

```go
// Requires: import as "github.com/aerospike/aerospike-client-go/v8"

make := as.ExpMapGetByKey(as.MapReturnType.VALUE, as.ExpTypeSTRING,

    as.ExpStringVal("make"),

    as.ExpListGetByIndex(as.ListReturnTypeValue, as.ExpTypeMAP, as.ExpIntVal(0),

        as.ExpListBin("vehicles")))

exp := as.ExpStringUpper(as.DefaultStringPolicy, make)
```

```javascript
const exp = Aerospike.exp

const lists = Aerospike.lists

const maps = Aerospike.maps

const make = exp.maps.getByKey(

  exp.lists.getByIndex(exp.binList('vehicles'), exp.int(0), exp.type.MAP,

    lists.returnType.VALUE),

  exp.str('make'), exp.type.STR, maps.returnType.VALUE)

const expression = exp.string.upper(null, make)
```

```c
as_exp_build(predexp,

  as_exp_string_upper(NULL,

    as_exp_map_get_by_key(NULL, AS_MAP_RETURN_VALUE, AS_EXP_TYPE_STR,

      as_exp_str("make"),

      as_exp_list_get_by_index(NULL, AS_LIST_RETURN_VALUE, AS_EXP_TYPE_MAP,

        as_exp_int(0), as_exp_bin_list("vehicles")))));
```

```java
import com.aerospike.client.cdt.ListReturnType;

import com.aerospike.client.cdt.MapReturnType;

import com.aerospike.client.exp.ListExp;

import com.aerospike.client.exp.MapExp;

import com.aerospike.client.exp.StringExp;

import com.aerospike.client.operation.StringPolicy;

Exp make = MapExp.getByKey(MapReturnType.VALUE, Exp.Type.STRING, Exp.val("make"),

  ListExp.getByIndex(ListReturnType.VALUE, Exp.Type.MAP, Exp.val(0),

    Exp.listBin("vehicles")));

Expression exp = Exp.build(StringExp.upper(StringPolicy.Default, make));
```

```python
import aerospike

from aerospike_helpers import expressions as exprs

from aerospike_helpers.expressions import string as str_expr

from aerospike_helpers.string_helpers import StringPolicy

make = exprs.MapGetByKey(

    ctx=None,

    return_type=aerospike.MAP_RETURN_VALUE,

    value_type=exprs.ResultType.STRING,

    key=exprs.Val("make"),

    bin=exprs.ListGetByIndex(

        ctx=None,

        return_type=aerospike.LIST_RETURN_VALUE,

        value_type=exprs.ResultType.MAP,

        index=exprs.Val(0),

        bin=exprs.ListBin("vehicles"),

    ),

)

exp = str_expr.Upper(StringPolicy(), bin=make).compile()
```

Run it like any other expression on this page: as a filter, or as a computed bin through an [operation expression](https://aerospike.com/docs/develop/learn/queries/projection#example-read-expression-in-projection).

In AEL the parentheses are load-bearing, and so is the `:STRING` pin. A string transform applied to a **path** — `$.vehicles.[0].make:STRING.upper()` — is a modify terminal, and evaluates to the whole `vehicles` list with that element transformed. Parenthesising the path first makes it a value, so the expression evaluates to the string alone. Without the type pin the server cannot infer the type and rejects the expression.

[`to_string`](#to_string) is the one operation with no Operate API context path. Project the nested value with a list or map getter and pass it as the source expression.

## Related guides

-   [String operations overview](https://aerospike.com/docs/develop/data-types/string)
-   [Compare String values](https://aerospike.com/docs/develop/data-types/string/comparison)
-   [Working with nested collection data types](https://aerospike.com/docs/develop/expressions/nesting)
-   [Upgrade to Database 8.2.0 and later](https://aerospike.com/docs/database/advanced/special-upgrades/820-upgrade#string-operations-and-utf-8-validation)

## Modify

#### `string_append`

`create_only` `update_only` `no_fail`

```python
string_append(policy, value, bin)
```

Description: Returns the string with `value` added to the end. Unlike the `append` Operate API operation, the expression form yields the new string as a value instead of writing it back to the bin. AEL text has no `append` function, and concatenates with the type-directed `+` operator instead. The Java, Python, and C helpers expose a named builder for consistency with the Operate API.

Arguments: | Name | Type | Description |
| --- | --- | --- |
| `policy` | `String policy` | 
Write flags for the transform. Optional, and defaults to none. With `NO_FAIL`, a failure that would abort the transform instead yields the source string unchanged, so the expression still produces a value. See [Operation flags](https://aerospike.com/docs/develop/data-types/string/operations#operation-flags) for which failures it suppresses.

 |
| `value` | `string` | 

Text to add to the end of the string. A single value, not a list.

 |
| `bin` | `string` | 

String bin to operate on, or any expression that evaluates to a string.

 |

Returns: `string`

Introduced: 8.2.0

Operate API operation: [`append`](https://aerospike.com/docs/develop/data-types/string/operations#append)

Example: Compose string expressions in query filters or `operate` read projections. Most clients take the policy first, the operands next, and the source string last. Go and Rust take the source string second, right after the policy.

-   [Java SDK](#tab-panel-2353)
-   [Python SDK](#tab-panel-2354)
-   [Rust](#tab-panel-2355)
-   [C#](#tab-panel-2356)
-   [Go](#tab-panel-2357)
-   [Node.js](#tab-panel-2358)
-   [C](#tab-panel-2359)
-   [Java](#tab-panel-2360)
-   [Python](#tab-panel-2361)

```java
// AEL has no append function; it concatenates with +.

String exp = "$.log:STRING + ' line'";
```

```python
# AEL has no append function; it concatenates with +.

exp = "$.log:STRING + ' line'"
```

```rust
use aerospike::expressions::{string as str_exp, string_bin, string_val};

use aerospike::operations::string::{StringPolicy};

let exp = str_exp::append(&StringPolicy::default(), string_bin("log".into()),

    string_val(" line".into()));
```

```csharp
using Aerospike.Client;

Expression exp = Exp.Build(

  StringExp.Append(StringPolicy.Default, Exp.Val(" line"),

    Exp.StringBin("log")));
```

```go
// Requires: import as "github.com/aerospike/aerospike-client-go/v8"

exp := as.ExpStringAppend(as.DefaultStringPolicy, as.ExpStringBin("log"),

    as.ExpStringVal(" line"))
```

```javascript
const exp = Aerospike.exp

const expression = exp.string.append(null, ' line', exp.binStr('log'))
```

```c
as_exp_build(predexp,

  as_exp_string_append(NULL, " line", as_exp_bin_str("log")));
```

```java
import com.aerospike.client.exp.StringExp;

import com.aerospike.client.operation.StringPolicy;

Expression exp = Exp.build(

  StringExp.append(StringPolicy.Default, Exp.val(" line"),

    Exp.stringBin("log")));
```

```python
from aerospike_helpers.expressions import string as str_expr

from aerospike_helpers.string_helpers import StringPolicy

exp = str_expr.Append(StringPolicy(), value=" line", bin="log").compile()
```

---

#### `string_case_fold`

`update_only` `no_fail`

```python
string_case_fold(policy, bin)
```

Description: Returns the Unicode case-folded form of a string expression, for case-insensitive comparison. Unlike the `case_fold` Operate API operation, the expression form yields the transformed string as a value instead of writing it back to the bin.

Arguments: | Name | Type | Description |
| --- | --- | --- |
| `policy` | `String policy` | 
Write flags for the transform. Optional, and defaults to none. With `NO_FAIL`, a failure that would abort the transform instead yields the source string unchanged, so the expression still produces a value. See [Operation flags](https://aerospike.com/docs/develop/data-types/string/operations#operation-flags) for which failures it suppresses.

 |
| `bin` | `string` | 

String bin to operate on, or any expression that evaluates to a string.

 |

Returns: `string`

Introduced: 8.2.0

Operate API operation: [`case_fold`](https://aerospike.com/docs/develop/data-types/string/operations#case_fold)

Example: Compose string expressions in query filters or `operate` read projections. Most clients take the policy first and the source string last. Go and Rust take the source string second, right after the policy.

-   [Java SDK](#tab-panel-2362)
-   [Python SDK](#tab-panel-2363)
-   [Rust](#tab-panel-2364)
-   [C#](#tab-panel-2365)
-   [Go](#tab-panel-2366)
-   [Node.js](#tab-panel-2367)
-   [C](#tab-panel-2368)
-   [Java](#tab-panel-2369)
-   [Python](#tab-panel-2370)

```java
String exp = "$.name:STRING.caseFold()";
```

```python
exp = "$.name:STRING.caseFold()"
```

```rust
use aerospike::expressions::{string as str_exp, string_bin};

use aerospike::operations::string::{StringPolicy};

let exp = str_exp::case_fold(&StringPolicy::default(), string_bin("name".into()));
```

```csharp
using Aerospike.Client;

Expression exp = Exp.Build(

  StringExp.CaseFold(StringPolicy.Default, Exp.StringBin("name")));
```

```go
// Requires: import as "github.com/aerospike/aerospike-client-go/v8"

exp := as.ExpStringCaseFold(as.DefaultStringPolicy, as.ExpStringBin("name"))
```

```javascript
const exp = Aerospike.exp

const expression = exp.string.caseFold(null, exp.binStr('name'))
```

```c
as_exp_build(predexp,

  as_exp_string_case_fold(NULL, as_exp_bin_str("name")));
```

```java
import com.aerospike.client.exp.StringExp;

import com.aerospike.client.operation.StringPolicy;

Expression exp = Exp.build(

  StringExp.caseFold(StringPolicy.Default, Exp.stringBin("name")));
```

```python
from aerospike_helpers.expressions import string as str_expr

from aerospike_helpers.string_helpers import StringPolicy

exp = str_expr.CaseFold(StringPolicy(), bin="name").compile()
```

---

#### `string_concat`

`create_only` `update_only` `no_fail`

```python
string_concat(policy, values, bin)
```

Description: Returns the string with `values` joined onto the end, in order. Unlike the `concat` Operate API operation, the expression form yields the new string as a value instead of writing it back to the bin. AEL text has no `concat` function, and concatenates with the type-directed `+` operator instead. The Java, Python, and C helpers expose a named builder for consistency with the Operate API.

Arguments: | Name | Type | Description |
| --- | --- | --- |
| `policy` | `String policy` | 
Write flags for the transform. Optional, and defaults to none. With `NO_FAIL`, a failure that would abort the transform instead yields the source string unchanged, so the expression still produces a value. See [Operation flags](https://aerospike.com/docs/develop/data-types/string/operations#operation-flags) for which failures it suppresses.

 |
| `values` | `any` | 

A list of strings to join onto the end, in order. The server operation always takes a list, so a single-value caller wraps it in a one-element list. Python accepts a list only, and the C client also provides a single-value form, `as_exp_string_concat`, alongside `as_exp_string_concat_list`.

 |
| `bin` | `string` | 

String bin to operate on, or any expression that evaluates to a string.

 |

Returns: `string`

Introduced: 8.2.0

Operate API operation: [`concat`](https://aerospike.com/docs/develop/data-types/string/operations#concat)

Example: Compose string expressions in query filters or `operate` read projections. Most clients take the policy first, the operands next, and the source string last. Go and Rust take the source string second, right after the policy.

-   [Java SDK](#tab-panel-2371)
-   [Python SDK](#tab-panel-2372)
-   [Rust](#tab-panel-2373)
-   [C#](#tab-panel-2374)
-   [Go](#tab-panel-2375)
-   [Node.js](#tab-panel-2376)
-   [C](#tab-panel-2377)
-   [Java](#tab-panel-2378)
-   [Python](#tab-panel-2379)

```java
// AEL has no concat function; it concatenates with +.

String exp = "$.tags:STRING + 'extra'";
```

```python
# AEL has no concat function; it concatenates with +.

exp = "$.tags:STRING + 'extra'"
```

```rust
use aerospike::expressions::{list_val, string as str_exp, string_bin};

use aerospike::operations::string::{StringPolicy};

use aerospike::Value;

let exp = str_exp::concat(&StringPolicy::default(), string_bin("tags".into()),

    list_val(vec![Value::from("extra")]));
```

```csharp
using System.Collections.Generic;

using Aerospike.Client;

Expression exp = Exp.Build(

  StringExp.Concat(StringPolicy.Default, Exp.Val(new List<string> { "extra" }),

    Exp.StringBin("tags")));
```

```go
// Requires: import as "github.com/aerospike/aerospike-client-go/v8"

exp := as.ExpStringConcat(as.DefaultStringPolicy, as.ExpStringBin("tags"),

    as.ExpListVal(as.StringValue("extra")))
```

```javascript
const exp = Aerospike.exp

const expression = exp.string.concat(null, 'extra', exp.binStr('tags'))
```

```c
as_exp_build(predexp,

  as_exp_string_concat(NULL, "extra", as_exp_bin_str("tags")));
```

```java
import com.aerospike.client.exp.StringExp;

import com.aerospike.client.operation.StringPolicy;

import java.util.List;

Expression exp = Exp.build(

  StringExp.concat(StringPolicy.Default, Exp.val(List.of("extra")),

    Exp.stringBin("tags")));
```

```python
from aerospike_helpers.expressions import string as str_expr

from aerospike_helpers.string_helpers import StringPolicy

exp = str_expr.Concat(

    StringPolicy(), values=["extra"], bin="tags"

).compile()
```

---

#### `string_insert`

`create_only` `update_only` `no_fail`

```python
string_insert(policy, offset, value, bin)
```

Description: Returns the string with `value` inserted at codepoint `offset`. Unlike the `insert` Operate API operation, the expression form yields the new string as a value instead of writing it back to the bin. AEL text calls this `splice` to disambiguate from the list and map `insert` functions. The Java, Python, and C helpers keep the `insert` name for consistency with the Operate API.

Arguments: | Name | Type | Description |
| --- | --- | --- |
| `policy` | `String policy` | 
Write flags for the transform. Optional, and defaults to none. With `NO_FAIL`, a failure that would abort the transform instead yields the source string unchanged, so the expression still produces a value. See [Operation flags](https://aerospike.com/docs/develop/data-types/string/operations#operation-flags) for which failures it suppresses.

 |
| `offset` | `integer` | 

Codepoint index at which to insert. Negative values count from the end of the string. Out-of-range values are clamped to `[0, length]`, so an offset equal to the length appends.

 |
| `value` | `string` | 

Text to insert.

 |
| `bin` | `string` | 

String bin to operate on, or any expression that evaluates to a string.

 |

Returns: `string`

Introduced: 8.2.0

Operate API operation: [`insert`](https://aerospike.com/docs/develop/data-types/string/operations#insert)

Example: Compose string expressions in query filters or `operate` read projections. Most clients take the policy first, the operands next, and the source string last. Go and Rust take the source string second, right after the policy.

-   [Java SDK](#tab-panel-2380)
-   [Python SDK](#tab-panel-2381)
-   [Rust](#tab-panel-2382)
-   [C#](#tab-panel-2383)
-   [Go](#tab-panel-2384)
-   [Node.js](#tab-panel-2385)
-   [C](#tab-panel-2386)
-   [Java](#tab-panel-2387)
-   [Python](#tab-panel-2388)

```java
// insert is splice in AEL, to avoid the list and map insert.

String exp = "$.text:STRING.splice(offset: 1, value: 'oh')";
```

```python
# insert is splice in AEL, to avoid the list and map insert.

exp = "$.text:STRING.splice(offset: 1, value: 'oh')"
```

```rust
use aerospike::expressions::{int_val, string as str_exp, string_bin, string_val};

use aerospike::operations::string::{StringPolicy};

let exp = str_exp::insert(&StringPolicy::default(), string_bin("text".into()),

    int_val(1), string_val("oh".into()));
```

```csharp
using Aerospike.Client;

Expression exp = Exp.Build(

  StringExp.Insert(StringPolicy.Default, Exp.Val(1), Exp.Val("oh"),

    Exp.StringBin("text")));
```

```go
// Requires: import as "github.com/aerospike/aerospike-client-go/v8"

exp := as.ExpStringInsert(as.DefaultStringPolicy, as.ExpStringBin("text"),

    as.ExpIntVal(1), as.ExpStringVal("oh"))
```

```javascript
const exp = Aerospike.exp

const expression = exp.string.insert(null, 1, 'oh', exp.binStr('text'))
```

```c
as_exp_build(predexp,

  as_exp_string_insert(NULL, 1, "oh", as_exp_bin_str("text")));
```

```java
import com.aerospike.client.exp.StringExp;

import com.aerospike.client.operation.StringPolicy;

Expression exp = Exp.build(

  StringExp.insert(StringPolicy.Default, Exp.val(1), Exp.val("oh"),

    Exp.stringBin("text")));
```

```python
from aerospike_helpers.expressions import string as str_expr

from aerospike_helpers.string_helpers import StringPolicy

exp = str_expr.Insert(

    StringPolicy(), index=1, value="oh", bin="text"

).compile()
```

---

#### `string_lower`

`update_only` `no_fail`

```python
string_lower(policy, bin)
```

Description: Returns the lowercase form of a string expression. Unlike the `lower` Operate API operation, the expression form yields the transformed string as a value instead of writing it back to the bin.

Arguments: | Name | Type | Description |
| --- | --- | --- |
| `policy` | `String policy` | 
Write flags for the transform. Optional, and defaults to none. With `NO_FAIL`, a failure that would abort the transform instead yields the source string unchanged, so the expression still produces a value. See [Operation flags](https://aerospike.com/docs/develop/data-types/string/operations#operation-flags) for which failures it suppresses.

 |
| `bin` | `string` | 

String bin to operate on, or any expression that evaluates to a string.

 |

Returns: `string`

Introduced: 8.2.0

Operate API operation: [`lower`](https://aerospike.com/docs/develop/data-types/string/operations#lower)

Example: Compose string expressions in query filters or `operate` read projections. Most clients take the policy first and the source string last. Go and Rust take the source string second, right after the policy.

-   [Java SDK](#tab-panel-2389)
-   [Python SDK](#tab-panel-2390)
-   [Rust](#tab-panel-2391)
-   [C#](#tab-panel-2392)
-   [Go](#tab-panel-2393)
-   [Node.js](#tab-panel-2394)
-   [C](#tab-panel-2395)
-   [Java](#tab-panel-2396)
-   [Python](#tab-panel-2397)

```java
String exp = "$.email:STRING.lower()";
```

```python
exp = "$.email:STRING.lower()"
```

```rust
use aerospike::expressions::{string as str_exp, string_bin};

use aerospike::operations::string::{StringPolicy};

let exp = str_exp::lower(&StringPolicy::default(), string_bin("email".into()));
```

```csharp
using Aerospike.Client;

Expression exp = Exp.Build(

  StringExp.Lower(StringPolicy.Default, Exp.StringBin("email")));
```

```go
// Requires: import as "github.com/aerospike/aerospike-client-go/v8"

exp := as.ExpStringLower(as.DefaultStringPolicy, as.ExpStringBin("email"))
```

```javascript
const exp = Aerospike.exp

const expression = exp.string.lower(null, exp.binStr('email'))
```

```c
as_exp_build(predexp,

  as_exp_string_lower(NULL, as_exp_bin_str("email")));
```

```java
import com.aerospike.client.exp.StringExp;

import com.aerospike.client.operation.StringPolicy;

Expression exp = Exp.build(

  StringExp.lower(StringPolicy.Default, Exp.stringBin("email")));
```

```python
from aerospike_helpers.expressions import string as str_expr

from aerospike_helpers.string_helpers import StringPolicy

exp = str_expr.Lower(StringPolicy(), bin="email").compile()
```

---

#### `string_normalize_nfc`

`update_only` `no_fail`

```python
string_normalize_nfc(policy, bin)
```

Description: Returns the Unicode NFC-normalized form of a string expression. Already-normalized strings are unchanged. Unlike the `normalize_nfc` Operate API operation, the expression form yields the transformed string as a value instead of writing it back to the bin. Use this so mixed NFC and NFD spellings compare equal under `eq`. See [Compare String values](https://aerospike.com/develop/data-types/string/comparison).

Arguments: | Name | Type | Description |
| --- | --- | --- |
| `policy` | `String policy` | 
Write flags for the transform. Optional, and defaults to none. With `NO_FAIL`, a failure that would abort the transform instead yields the source string unchanged, so the expression still produces a value. See [Operation flags](https://aerospike.com/docs/develop/data-types/string/operations#operation-flags) for which failures it suppresses.

 |
| `bin` | `string` | 

String bin to operate on, or any expression that evaluates to a string.

 |

Returns: `string`

Introduced: 8.2.0

Operate API operation: [`normalize_nfc`](https://aerospike.com/docs/develop/data-types/string/operations#normalize_nfc)

Example: Compose string expressions in query filters or `operate` read projections. Most clients take the policy first and the source string last. Go and Rust take the source string second, right after the policy.

-   [Java SDK](#tab-panel-2398)
-   [Python SDK](#tab-panel-2399)
-   [Rust](#tab-panel-2400)
-   [C#](#tab-panel-2401)
-   [Go](#tab-panel-2402)
-   [Node.js](#tab-panel-2403)
-   [C](#tab-panel-2404)
-   [Java](#tab-panel-2405)
-   [Python](#tab-panel-2406)

```java
String exp = "$.name:STRING.normalizeNFC()";
```

```python
exp = "$.name:STRING.normalizeNFC()"
```

```rust
use aerospike::expressions::{string as str_exp, string_bin};

use aerospike::operations::string::{StringPolicy};

let exp = str_exp::normalize_nfc(&StringPolicy::default(), string_bin("name".into()));
```

```csharp
using Aerospike.Client;

Expression exp = Exp.Build(

  StringExp.NormalizeNFC(StringPolicy.Default, Exp.StringBin("name")));
```

```go
// Requires: import as "github.com/aerospike/aerospike-client-go/v8"

exp := as.ExpStringNormalizeNFC(as.DefaultStringPolicy, as.ExpStringBin("name"))
```

```javascript
const exp = Aerospike.exp

const expression = exp.string.normalizeNfc(null, exp.binStr('name'))
```

```c
as_exp_build(predexp,

  as_exp_string_normalize_nfc(NULL, as_exp_bin_str("name")));
```

```java
import com.aerospike.client.exp.StringExp;

import com.aerospike.client.operation.StringPolicy;

Expression exp = Exp.build(

  StringExp.normalizeNFC(StringPolicy.Default, Exp.stringBin("name")));
```

```python
from aerospike_helpers.expressions import string as str_expr

from aerospike_helpers.string_helpers import StringPolicy

exp = str_expr.NormalizeNFC(StringPolicy(), bin="name").compile()
```

---

#### `string_overwrite`

`create_only` `update_only` `no_fail`

```python
string_overwrite(policy, offset, value, bin)
```

Description: Returns the string with the codepoint range starting at `offset` overwritten by `value`. The result grows beyond the original length when `value` extends past the end. Unlike the `overwrite` Operate API operation, the expression form yields the new string as a value instead of writing it back to the bin.

Arguments: | Name | Type | Description |
| --- | --- | --- |
| `policy` | `String policy` | 
Write flags for the transform. Optional, and defaults to none. With `NO_FAIL`, a failure that would abort the transform instead yields the source string unchanged, so the expression still produces a value. See [Operation flags](https://aerospike.com/docs/develop/data-types/string/operations#operation-flags) for which failures it suppresses.

 |
| `offset` | `integer` | 

Codepoint index at which to start overwriting. Negative values count from the end of the string, as they do for `string_insert`, `string_char_at`, `string_substr`, and `string_snip`. The resolved index must satisfy `0 <= offset < length`. Outside that range the expression returns an error rather than being clamped. On an empty source string the only accepted offset is `0`.

 |
| `value` | `string` | 

Replacement text.

 |
| `bin` | `string` | 

String bin to operate on, or any expression that evaluates to a string.

 |

Returns: `string`

Introduced: 8.2.0

Operate API operation: [`overwrite`](https://aerospike.com/docs/develop/data-types/string/operations#overwrite)

Example: Compose string expressions in query filters or `operate` read projections. Most clients take the policy first, the operands next, and the source string last. Go and Rust take the source string second, right after the policy.

-   [Java SDK](#tab-panel-2407)
-   [Python SDK](#tab-panel-2408)
-   [Rust](#tab-panel-2409)
-   [C#](#tab-panel-2410)
-   [Go](#tab-panel-2411)
-   [Node.js](#tab-panel-2412)
-   [C](#tab-panel-2413)
-   [Java](#tab-panel-2414)
-   [Python](#tab-panel-2415)

```java
String exp = "$.text:STRING.overwrite(offset: 4, value: 'bleh')";
```

```python
exp = "$.text:STRING.overwrite(offset: 4, value: 'bleh')"
```

```rust
use aerospike::expressions::{int_val, string as str_exp, string_bin, string_val};

use aerospike::operations::string::{StringPolicy};

let exp = str_exp::overwrite(&StringPolicy::default(), string_bin("text".into()),

    int_val(4), string_val("bleh".into()));
```

```csharp
using Aerospike.Client;

Expression exp = Exp.Build(

  StringExp.Overwrite(StringPolicy.Default, Exp.Val(4), Exp.Val("bleh"),

    Exp.StringBin("text")));
```

```go
// Requires: import as "github.com/aerospike/aerospike-client-go/v8"

exp := as.ExpStringOverwrite(as.DefaultStringPolicy, as.ExpStringBin("text"),

    as.ExpIntVal(4), as.ExpStringVal("bleh"))
```

```javascript
const exp = Aerospike.exp

const expression = exp.string.overwrite(null, 4, 'bleh', exp.binStr('text'))
```

```c
as_exp_build(predexp,

  as_exp_string_overwrite(NULL, 4, "bleh", as_exp_bin_str("text")));
```

```java
import com.aerospike.client.exp.StringExp;

import com.aerospike.client.operation.StringPolicy;

Expression exp = Exp.build(

  StringExp.overwrite(StringPolicy.Default, Exp.val(4), Exp.val("bleh"),

    Exp.stringBin("text")));
```

```python
from aerospike_helpers.expressions import string as str_expr

from aerospike_helpers.string_helpers import StringPolicy

exp = str_expr.Overwrite(

    StringPolicy(), index=4, value="bleh", bin="text"

).compile()
```

---

#### `string_pad_end`

`create_only` `update_only` `no_fail`

```python
string_pad_end(policy, target_length, pad_string, bin)
```

Description: Returns the string padded at the end to `target_length` using `pad_string`. No change is made when the source is already at or above the target length. Unlike the `pad_end` Operate API operation, the expression form yields the padded string as a value instead of writing it back to the bin.

Arguments: | Name | Type | Description |
| --- | --- | --- |
| `policy` | `String policy` | 
Write flags for the transform. Optional, and defaults to none. With `NO_FAIL`, a failure that would abort the transform instead yields the source string unchanged, so the expression still produces a value. See [Operation flags](https://aerospike.com/docs/develop/data-types/string/operations#operation-flags) for which failures it suppresses.

 |
| `target_length` | `integer` | 

Minimum codepoint length after padding.

 |
| `pad_string` | `string` | 

Padding string.

 |
| `bin` | `string` | 

String bin to operate on, or any expression that evaluates to a string.

 |

Returns: `string`

Introduced: 8.2.0

Operate API operation: [`pad_end`](https://aerospike.com/docs/develop/data-types/string/operations#pad_end)

Example: Compose string expressions in query filters or `operate` read projections. Most clients take the policy first, the operands next, and the source string last. Go and Rust take the source string second, right after the policy.

-   [Java SDK](#tab-panel-2416)
-   [Python SDK](#tab-panel-2417)
-   [Rust](#tab-panel-2418)
-   [C#](#tab-panel-2419)
-   [Go](#tab-panel-2420)
-   [Node.js](#tab-panel-2421)
-   [C](#tab-panel-2422)
-   [Java](#tab-panel-2423)
-   [Python](#tab-panel-2424)

```java
String exp = "$.id:STRING.padEnd(length: 6, pad: '0')";
```

```python
exp = "$.id:STRING.padEnd(length: 6, pad: '0')"
```

```rust
use aerospike::expressions::{int_val, string as str_exp, string_bin, string_val};

use aerospike::operations::string::{StringPolicy};

let exp = str_exp::pad_end(&StringPolicy::default(), string_bin("id".into()),

    int_val(6), string_val("0".into()));
```

```csharp
using Aerospike.Client;

Expression exp = Exp.Build(

  StringExp.PadEnd(StringPolicy.Default, Exp.Val(6), Exp.Val("0"),

    Exp.StringBin("id")));
```

```go
// Requires: import as "github.com/aerospike/aerospike-client-go/v8"

exp := as.ExpStringPadEnd(as.DefaultStringPolicy, as.ExpStringBin("id"),

    as.ExpIntVal(6), as.ExpStringVal("0"))
```

```javascript
const exp = Aerospike.exp

const expression = exp.string.padEnd(null, 6, '0', exp.binStr('id'))
```

```c
as_exp_build(predexp,

  as_exp_string_pad_end(NULL, 6, "0", as_exp_bin_str("id")));
```

```java
import com.aerospike.client.exp.StringExp;

import com.aerospike.client.operation.StringPolicy;

Expression exp = Exp.build(

  StringExp.padEnd(StringPolicy.Default, Exp.val(6), Exp.val("0"),

    Exp.stringBin("id")));
```

```python
from aerospike_helpers.expressions import string as str_expr

from aerospike_helpers.string_helpers import StringPolicy

exp = str_expr.PadEnd(

    StringPolicy(), target_length=6, pad_string="0", bin="id"

).compile()
```

---

#### `string_pad_start`

`create_only` `update_only` `no_fail`

```python
string_pad_start(policy, target_length, pad_string, bin)
```

Description: Returns the string padded at the start to `target_length` using `pad_string`. No change is made when the source is already at or above the target length. Unlike the `pad_start` Operate API operation, the expression form yields the padded string as a value instead of writing it back to the bin.

Arguments: | Name | Type | Description |
| --- | --- | --- |
| `policy` | `String policy` | 
Write flags for the transform. Optional, and defaults to none. With `NO_FAIL`, a failure that would abort the transform instead yields the source string unchanged, so the expression still produces a value. See [Operation flags](https://aerospike.com/docs/develop/data-types/string/operations#operation-flags) for which failures it suppresses.

 |
| `target_length` | `integer` | 

Minimum codepoint length after padding.

 |
| `pad_string` | `string` | 

Padding string.

 |
| `bin` | `string` | 

String bin to operate on, or any expression that evaluates to a string.

 |

Returns: `string`

Introduced: 8.2.0

Operate API operation: [`pad_start`](https://aerospike.com/docs/develop/data-types/string/operations#pad_start)

Example: Compose string expressions in query filters or `operate` read projections. Most clients take the policy first, the operands next, and the source string last. Go and Rust take the source string second, right after the policy.

-   [Java SDK](#tab-panel-2425)
-   [Python SDK](#tab-panel-2426)
-   [Rust](#tab-panel-2427)
-   [C#](#tab-panel-2428)
-   [Go](#tab-panel-2429)
-   [Node.js](#tab-panel-2430)
-   [C](#tab-panel-2431)
-   [Java](#tab-panel-2432)
-   [Python](#tab-panel-2433)

```java
String exp = "$.id:STRING.padStart(length: 6, pad: '0')";
```

```python
exp = "$.id:STRING.padStart(length: 6, pad: '0')"
```

```rust
use aerospike::expressions::{int_val, string as str_exp, string_bin, string_val};

use aerospike::operations::string::{StringPolicy};

let exp = str_exp::pad_start(&StringPolicy::default(), string_bin("id".into()),

    int_val(6), string_val("0".into()));
```

```csharp
using Aerospike.Client;

Expression exp = Exp.Build(

  StringExp.PadStart(StringPolicy.Default, Exp.Val(6), Exp.Val("0"),

    Exp.StringBin("id")));
```

```go
// Requires: import as "github.com/aerospike/aerospike-client-go/v8"

exp := as.ExpStringPadStart(as.DefaultStringPolicy, as.ExpStringBin("id"),

    as.ExpIntVal(6), as.ExpStringVal("0"))
```

```javascript
const exp = Aerospike.exp

const expression = exp.string.padStart(null, 6, '0', exp.binStr('id'))
```

```c
as_exp_build(predexp,

  as_exp_string_pad_start(NULL, 6, "0", as_exp_bin_str("id")));
```

```java
import com.aerospike.client.exp.StringExp;

import com.aerospike.client.operation.StringPolicy;

Expression exp = Exp.build(

  StringExp.padStart(StringPolicy.Default, Exp.val(6), Exp.val("0"),

    Exp.stringBin("id")));
```

```python
from aerospike_helpers.expressions import string as str_expr

from aerospike_helpers.string_helpers import StringPolicy

exp = str_expr.PadStart(

    StringPolicy(), target_length=6, pad_string="0", bin="id"

).compile()
```

---

#### `string_prepend`

`create_only` `update_only` `no_fail`

```python
string_prepend(policy, value, bin)
```

Description: Returns the string with `value` added to the start. Unlike the `prepend` Operate API operation, the expression form yields the new string as a value instead of writing it back to the bin. AEL text has no `prepend` function, and concatenates with the type-directed `+` operator instead. The Java, Python, and C helpers expose a named builder for consistency with the Operate API.

Arguments: | Name | Type | Description |
| --- | --- | --- |
| `policy` | `String policy` | 
Write flags for the transform. Optional, and defaults to none. With `NO_FAIL`, a failure that would abort the transform instead yields the source string unchanged, so the expression still produces a value. See [Operation flags](https://aerospike.com/docs/develop/data-types/string/operations#operation-flags) for which failures it suppresses.

 |
| `value` | `string` | 

Text to add to the start of the string. A single value, not a list.

 |
| `bin` | `string` | 

String bin to operate on, or any expression that evaluates to a string.

 |

Returns: `string`

Introduced: 8.2.0

Operate API operation: [`prepend`](https://aerospike.com/docs/develop/data-types/string/operations#prepend)

Example: Compose string expressions in query filters or `operate` read projections. Most clients take the policy first, the operands next, and the source string last. Go and Rust take the source string second, right after the policy.

-   [Java SDK](#tab-panel-2434)
-   [Python SDK](#tab-panel-2435)
-   [Rust](#tab-panel-2436)
-   [C#](#tab-panel-2437)
-   [Go](#tab-panel-2438)
-   [Node.js](#tab-panel-2439)
-   [C](#tab-panel-2440)
-   [Java](#tab-panel-2441)
-   [Python](#tab-panel-2442)

```java
// AEL has no prepend function; it concatenates with +.

String exp = "'prefix: ' + $.log:STRING";
```

```python
# AEL has no prepend function; it concatenates with +.

exp = "'prefix: ' + $.log:STRING"
```

```rust
use aerospike::expressions::{string as str_exp, string_bin, string_val};

use aerospike::operations::string::{StringPolicy};

let exp = str_exp::prepend(&StringPolicy::default(), string_bin("log".into()),

    string_val("prefix: ".into()));
```

```csharp
using Aerospike.Client;

Expression exp = Exp.Build(

  StringExp.Prepend(StringPolicy.Default, Exp.Val("prefix: "),

    Exp.StringBin("log")));
```

```go
// Requires: import as "github.com/aerospike/aerospike-client-go/v8"

exp := as.ExpStringPrepend(as.DefaultStringPolicy, as.ExpStringBin("log"),

    as.ExpStringVal("prefix: "))
```

```javascript
const exp = Aerospike.exp

const expression = exp.string.prepend(null, 'prefix: ', exp.binStr('log'))
```

```c
as_exp_build(predexp,

  as_exp_string_prepend(NULL, "prefix: ", as_exp_bin_str("log")));
```

```java
import com.aerospike.client.exp.StringExp;

import com.aerospike.client.operation.StringPolicy;

Expression exp = Exp.build(

  StringExp.prepend(StringPolicy.Default, Exp.val("prefix: "),

    Exp.stringBin("log")));
```

```python
from aerospike_helpers.expressions import string as str_expr

from aerospike_helpers.string_helpers import StringPolicy

exp = str_expr.Prepend(

    StringPolicy(), value="prefix: ", bin="log"

).compile()
```

---

#### `string_regex_replace`

`update_only` `no_fail`

```python
string_regex_replace(policy, pattern, replacement, regex_flags, bin)
```

Description: Returns the string with the first regex match replaced by `replacement`, or every match when the `GLOBAL` flag is set. Unlike the `regex_replace` Operate API operation, the expression form yields the new string as a value instead of writing it back to the bin.

Arguments: | Name | Type | Description |
| --- | --- | --- |
| `policy` | `String policy` | 
Write regex\_flags for the transform. Optional, and defaults to none. With `NO_FAIL`, a failure that would abort the transform instead yields the source string unchanged, so the expression still produces a value. See [Operation flags](https://aerospike.com/docs/develop/data-types/string/operations#operation-flags) for which failures it suppresses.

 |
| `pattern` | `string literal` | 

Regular expression pattern.

 |
| `replacement` | `string literal` | 

Replacement text.

 |
| `regex_flags` | `integer literal` | 

Bit field of regex regex\_flags on the six client-builder tabs, combinable with bitwise OR. Defaults to none, which replaces only the first match; `GLOBAL` (16) replaces every match. The two SDK tabs take AEL text, which has no regex\_flags argument at all — regex\_flags there are letters appended to the regex literal, as in `/\d+/g`. For the values, their effects, the AEL letters, and why these must not be confused with the write policy above, see [Regex flags](https://aerospike.com/develop/data-types/string/regex-syntax#flags).

 |
| `bin` | `string` | 

String bin to operate on, or any expression that evaluates to a string.

 |

Returns: `string`

Introduced: 8.2.0

Operate API operation: [`regex_replace`](https://aerospike.com/docs/develop/data-types/string/operations#regex_replace)

Example: Without `GLOBAL`, only the first match is replaced. Every client takes the policy first, the operands next, and the source string last.

-   [Java SDK](#tab-panel-2443)
-   [Python SDK](#tab-panel-2444)
-   [Rust](#tab-panel-2445)
-   [C#](#tab-panel-2446)
-   [Go](#tab-panel-2447)
-   [Node.js](#tab-panel-2448)
-   [C](#tab-panel-2449)
-   [Java](#tab-panel-2450)
-   [Python](#tab-panel-2451)

```java
// The /g flag replaces every match; without it only the first is replaced.

String exp = "$.text:STRING.regexReplace(pattern: /\\d+/g, replace: '')";
```

```python
# The /g flag replaces every match; without it only the first is replaced.

exp = r"$.text:STRING.regexReplace(pattern: /\d+/g, replace: '')"
```

```rust
use aerospike::expressions::{string as str_exp, string_bin, string_val};

use aerospike::operations::string::{StringPolicy, StringRegexFlags};

let exp = str_exp::regex_replace(&StringPolicy::default(), string_bin("text".into()),

    string_val(r"\d+".into()), string_val("".into()), StringRegexFlags::GLOBAL);
```

```csharp
using Aerospike.Client;

Expression exp = Exp.Build(

  StringExp.RegexReplace(StringPolicy.Default, Exp.Val(@"\d+"), Exp.Val(""),

    StringRegexFlags.GLOBAL, Exp.StringBin("text")));
```

```go
// Requires: import as "github.com/aerospike/aerospike-client-go/v8"

exp := as.ExpStringRegexReplace(as.DefaultStringPolicy, as.ExpStringBin("text"),

    as.ExpStringVal(`\d+`), as.ExpStringVal(""), as.StringRegexGlobal)
```

```javascript
const exp = Aerospike.exp

const strings = Aerospike.strings

const expression = exp.string.regexReplace(null, '\\d+', '',

  strings.regexFlags.GLOBAL, exp.binStr('text'))
```

```c
as_exp_build(predexp,

  as_exp_string_regex_replace(NULL, "\\d+", "",

    AS_STRING_REGEX_FLAGS_GLOBAL, as_exp_bin_str("text")));
```

```java
import com.aerospike.client.exp.StringExp;

import com.aerospike.client.operation.StringPolicy;

import com.aerospike.client.operation.StringRegexFlags;

Expression exp = Exp.build(

  StringExp.regexReplace(StringPolicy.Default, Exp.val("\\d+"), Exp.val(""),

    StringRegexFlags.GLOBAL, Exp.stringBin("text")));
```

```python
from aerospike_helpers.expressions import string as str_expr

from aerospike_helpers.string_helpers import StringPolicy, RegexFlags

exp = str_expr.RegexReplace(

    StringPolicy(), pattern=r"\d+", replacement="",

    regex_flags=RegexFlags.GLOBAL, bin="text"

).compile()
```

---

#### `string_repeat`

`create_only` `update_only` `no_fail`

```python
string_repeat(policy, count, bin)
```

Description: Returns the string repeated `count` times. Unlike the `repeat` Operate API operation, the expression form yields the new string as a value instead of writing it back to the bin.

Arguments: | Name | Type | Description |
| --- | --- | --- |
| `policy` | `String policy` | 
Write flags for the transform. Optional, and defaults to none. With `NO_FAIL`, a failure that would abort the transform instead yields the source string unchanged, so the expression still produces a value. See [Operation flags](https://aerospike.com/docs/develop/data-types/string/operations#operation-flags) for which failures it suppresses.

 |
| `count` | `integer` | 

Number of times to repeat the string. Must be non-negative. A negative count returns an error. A count of `0` yields the empty string.

 |
| `bin` | `string` | 

String bin to operate on, or any expression that evaluates to a string.

 |

Returns: `string`

Introduced: 8.2.0

Operate API operation: [`repeat`](https://aerospike.com/docs/develop/data-types/string/operations#repeat)

Example: Compose string expressions in query filters or `operate` read projections. Most clients take the policy first, the operands next, and the source string last. Go and Rust take the source string second, right after the policy.

-   [Java SDK](#tab-panel-2452)
-   [Python SDK](#tab-panel-2453)
-   [Rust](#tab-panel-2454)
-   [C#](#tab-panel-2455)
-   [Go](#tab-panel-2456)
-   [Node.js](#tab-panel-2457)
-   [C](#tab-panel-2458)
-   [Java](#tab-panel-2459)
-   [Python](#tab-panel-2460)

```java
String exp = "$.unit:STRING.repeat(3)";
```

```python
exp = "$.unit:STRING.repeat(3)"
```

```rust
use aerospike::expressions::{int_val, string as str_exp, string_bin};

use aerospike::operations::string::{StringPolicy};

let exp = str_exp::repeat(&StringPolicy::default(), string_bin("unit".into()), int_val(3));
```

```csharp
using Aerospike.Client;

Expression exp = Exp.Build(

  StringExp.Repeat(StringPolicy.Default, Exp.Val(3), Exp.StringBin("unit")));
```

```go
// Requires: import as "github.com/aerospike/aerospike-client-go/v8"

exp := as.ExpStringRepeat(as.DefaultStringPolicy, as.ExpStringBin("unit"),

    as.ExpIntVal(3))
```

```javascript
const exp = Aerospike.exp

const expression = exp.string.repeat(null, 3, exp.binStr('unit'))
```

```c
as_exp_build(predexp,

  as_exp_string_repeat(NULL, 3, as_exp_bin_str("unit")));
```

```java
import com.aerospike.client.exp.StringExp;

import com.aerospike.client.operation.StringPolicy;

Expression exp = Exp.build(

  StringExp.repeat(StringPolicy.Default, Exp.val(3), Exp.stringBin("unit")));
```

```python
from aerospike_helpers.expressions import string as str_expr

from aerospike_helpers.string_helpers import StringPolicy

exp = str_expr.Repeat(StringPolicy(), count=3, bin="unit").compile()
```

---

#### `string_replace`

`update_only` `no_fail`

```python
string_replace(policy, find, replace, bin)
```

Description: Returns the string with the first occurrence of `find` replaced by `replace`. Unlike the `replace` Operate API operation, the expression form yields the new string as a value instead of writing it back to the bin.

Arguments: | Name | Type | Description |
| --- | --- | --- |
| `policy` | `String policy` | 
Write flags for the transform. Optional, and defaults to none. With `NO_FAIL`, a failure that would abort the transform instead yields the source string unchanged, so the expression still produces a value. See [Operation flags](https://aerospike.com/docs/develop/data-types/string/operations#operation-flags) for which failures it suppresses.

 |
| `find` | `string literal` | 

Substring to replace.

 |
| `replace` | `string literal` | 

Replacement text.

 |
| `bin` | `string` | 

String bin to operate on, or any expression that evaluates to a string.

 |

Returns: `string`

Introduced: 8.2.0

Operate API operation: [`replace`](https://aerospike.com/docs/develop/data-types/string/operations#replace)

Example: Compose string expressions in query filters or `operate` read projections. Most clients take the policy first, the operands next, and the source string last. Go and Rust take the source string second, right after the policy.

-   [Java SDK](#tab-panel-2461)
-   [Python SDK](#tab-panel-2462)
-   [Rust](#tab-panel-2463)
-   [C#](#tab-panel-2464)
-   [Go](#tab-panel-2465)
-   [Node.js](#tab-panel-2466)
-   [C](#tab-panel-2467)
-   [Java](#tab-panel-2468)
-   [Python](#tab-panel-2469)

```java
String exp = "$.msg:STRING.replace(find: 'old', replace: 'new')";
```

```python
exp = "$.msg:STRING.replace(find: 'old', replace: 'new')"
```

```rust
use aerospike::expressions::{string as str_exp, string_bin, string_val};

use aerospike::operations::string::{StringPolicy};

let exp = str_exp::replace(&StringPolicy::default(), string_bin("msg".into()),

    string_val("old".into()), string_val("new".into()));
```

```csharp
using Aerospike.Client;

Expression exp = Exp.Build(

  StringExp.Replace(StringPolicy.Default, Exp.Val("old"), Exp.Val("new"),

    Exp.StringBin("msg")));
```

```go
// Requires: import as "github.com/aerospike/aerospike-client-go/v8"

exp := as.ExpStringReplace(as.DefaultStringPolicy, as.ExpStringBin("msg"),

    as.ExpStringVal("old"), as.ExpStringVal("new"))
```

```javascript
const exp = Aerospike.exp

const expression = exp.string.replace(null, 'old', 'new', exp.binStr('msg'))
```

```c
as_exp_build(predexp,

  as_exp_string_replace(NULL, "old", "new", as_exp_bin_str("msg")));
```

```java
import com.aerospike.client.exp.StringExp;

import com.aerospike.client.operation.StringPolicy;

Expression exp = Exp.build(

  StringExp.replace(StringPolicy.Default, Exp.val("old"), Exp.val("new"),

    Exp.stringBin("msg")));
```

```python
from aerospike_helpers.expressions import string as str_expr

from aerospike_helpers.string_helpers import StringPolicy

exp = str_expr.Replace(

    StringPolicy(), needle="old", replacement="new", bin="msg"

).compile()
```

---

#### `string_replace_all`

`update_only` `no_fail`

```python
string_replace_all(policy, find, replace, bin)
```

Description: Returns the string with every occurrence of `find` replaced by `replace`. Unlike the `replace_all` Operate API operation, the expression form yields the new string as a value instead of writing it back to the bin.

Arguments: | Name | Type | Description |
| --- | --- | --- |
| `policy` | `String policy` | 
Write flags for the transform. Optional, and defaults to none. With `NO_FAIL`, a failure that would abort the transform instead yields the source string unchanged, so the expression still produces a value. See [Operation flags](https://aerospike.com/docs/develop/data-types/string/operations#operation-flags) for which failures it suppresses.

 |
| `find` | `string literal` | 

Substring to replace.

 |
| `replace` | `string literal` | 

Replacement text.

 |
| `bin` | `string` | 

String bin to operate on, or any expression that evaluates to a string.

 |

Returns: `string`

Introduced: 8.2.0

Operate API operation: [`replace_all`](https://aerospike.com/docs/develop/data-types/string/operations#replace_all)

Example: Compose string expressions in query filters or `operate` read projections. Most clients take the policy first, the operands next, and the source string last. Go and Rust take the source string second, right after the policy.

-   [Java SDK](#tab-panel-2470)
-   [Python SDK](#tab-panel-2471)
-   [Rust](#tab-panel-2472)
-   [C#](#tab-panel-2473)
-   [Go](#tab-panel-2474)
-   [Node.js](#tab-panel-2475)
-   [C](#tab-panel-2476)
-   [Java](#tab-panel-2477)
-   [Python](#tab-panel-2478)

```java
String exp = "$.msg:STRING.replaceAll(find: 'old', replace: 'new')";
```

```python
exp = "$.msg:STRING.replaceAll(find: 'old', replace: 'new')"
```

```rust
use aerospike::expressions::{string as str_exp, string_bin, string_val};

use aerospike::operations::string::{StringPolicy};

let exp = str_exp::replace_all(&StringPolicy::default(), string_bin("msg".into()),

    string_val("old".into()), string_val("new".into()));
```

```csharp
using Aerospike.Client;

Expression exp = Exp.Build(

  StringExp.ReplaceAll(StringPolicy.Default, Exp.Val("old"), Exp.Val("new"),

    Exp.StringBin("msg")));
```

```go
// Requires: import as "github.com/aerospike/aerospike-client-go/v8"

exp := as.ExpStringReplaceAll(as.DefaultStringPolicy, as.ExpStringBin("msg"),

    as.ExpStringVal("old"), as.ExpStringVal("new"))
```

```javascript
const exp = Aerospike.exp

const expression = exp.string.replaceAll(null, 'old', 'new', exp.binStr('msg'))
```

```c
as_exp_build(predexp,

  as_exp_string_replace_all(NULL, "old", "new", as_exp_bin_str("msg")));
```

```java
import com.aerospike.client.exp.StringExp;

import com.aerospike.client.operation.StringPolicy;

Expression exp = Exp.build(

  StringExp.replaceAll(StringPolicy.Default, Exp.val("old"), Exp.val("new"),

    Exp.stringBin("msg")));
```

```python
from aerospike_helpers.expressions import string as str_expr

from aerospike_helpers.string_helpers import StringPolicy

exp = str_expr.ReplaceAll(

    StringPolicy(), needle="old", replacement="new", bin="msg"

).compile()
```

---

#### `string_snip`

`update_only` `no_fail`

```python
string_snip(policy, from[, to], bin)
```

Description: Returns the string with the codepoint range from `from` (inclusive) to `to` (exclusive) removed. Unlike the `snip` Operate API operation, the expression form yields the new string as a value instead of writing it back to the bin.

Arguments: | Name | Type | Description |
| --- | --- | --- |
| `policy` | `String policy` | 
Write flags for the transform. Optional, and defaults to none. With `NO_FAIL`, a failure that would abort the transform instead yields the source string unchanged, so the expression still produces a value. See [Operation flags](https://aerospike.com/docs/develop/data-types/string/operations#operation-flags) for which failures it suppresses.

 |
| `from` | `integer` | 

Start codepoint index (inclusive). Negative values count from the end of the string. Out-of-range values are clamped to `[0, length]`.

 |
| `to` | `integer` | 

End codepoint index (exclusive). Negative values count from the end of the string. Out-of-range values are clamped to `[0, length]`. Optional, and defaults to the string’s codepoint length, removing everything from `from` to the end of the string.

 |
| `bin` | `string` | 

String bin to operate on, or any expression that evaluates to a string.

 |

Returns: `string`

Introduced: 8.2.0

Operate API operation: [`snip`](https://aerospike.com/docs/develop/data-types/string/operations#snip)

Example: Compose string expressions in query filters or `operate` read projections. Most clients take the policy first, the operands next, and the source string last. Go and Rust take the source string second, right after the policy.

-   [Java SDK](#tab-panel-2479)
-   [Python SDK](#tab-panel-2480)
-   [Rust](#tab-panel-2481)
-   [C#](#tab-panel-2482)
-   [Go](#tab-panel-2483)
-   [Node.js](#tab-panel-2484)
-   [C](#tab-panel-2485)
-   [Java](#tab-panel-2486)
-   [Python](#tab-panel-2487)

```java
String exp = "$.text:STRING.snip(from: 6, to: 9)";
```

```python
exp = "$.text:STRING.snip(from: 6, to: 9)"
```

```rust
use aerospike::expressions::{int_val, string as str_exp, string_bin};

use aerospike::operations::string::{StringPolicy};

let exp = str_exp::snip(&StringPolicy::default(), string_bin("text".into()),

    int_val(6), int_val(9));
```

```csharp
using Aerospike.Client;

Expression exp = Exp.Build(

  StringExp.Snip(StringPolicy.Default, Exp.Val(6), Exp.Val(9),

    Exp.StringBin("text")));
```

```go
// Requires: import as "github.com/aerospike/aerospike-client-go/v8"

exp := as.ExpStringSnip(as.DefaultStringPolicy, as.ExpStringBin("text"),

    as.ExpIntVal(6), as.ExpIntVal(9))
```

```javascript
const exp = Aerospike.exp

const expression = exp.string.snip(null, 6, 9, exp.binStr('text'))
```

```c
as_exp_build(predexp,

  as_exp_string_snip(NULL, 6, 9, as_exp_bin_str("text")));
```

```java
import com.aerospike.client.exp.StringExp;

import com.aerospike.client.operation.StringPolicy;

Expression exp = Exp.build(

  StringExp.snip(StringPolicy.Default, Exp.val(6), Exp.val(9),

    Exp.stringBin("text")));
```

```python
from aerospike_helpers.expressions import string as str_expr

from aerospike_helpers.string_helpers import StringPolicy

exp = str_expr.Snip(StringPolicy(), start=6, end=9, bin="text").compile()
```

---

#### `string_trim`

`update_only` `no_fail`

```python
string_trim(policy, bin)
```

Description: Returns the string with leading and trailing Unicode whitespace removed. Unlike the `trim` Operate API operation, the expression form yields the transformed string as a value instead of writing it back to the bin.

Arguments: | Name | Type | Description |
| --- | --- | --- |
| `policy` | `String policy` | 
Write flags for the transform. Optional, and defaults to none. With `NO_FAIL`, a failure that would abort the transform instead yields the source string unchanged, so the expression still produces a value. See [Operation flags](https://aerospike.com/docs/develop/data-types/string/operations#operation-flags) for which failures it suppresses.

 |
| `bin` | `string` | 

String bin to operate on, or any expression that evaluates to a string.

 |

Returns: `string`

Introduced: 8.2.0

Operate API operation: [`trim`](https://aerospike.com/docs/develop/data-types/string/operations#trim)

Example: Compose string expressions in query filters or `operate` read projections. Most clients take the policy first and the source string last. Go and Rust take the source string second, right after the policy.

-   [Java SDK](#tab-panel-2488)
-   [Python SDK](#tab-panel-2489)
-   [Rust](#tab-panel-2490)
-   [C#](#tab-panel-2491)
-   [Go](#tab-panel-2492)
-   [Node.js](#tab-panel-2493)
-   [C](#tab-panel-2494)
-   [Java](#tab-panel-2495)
-   [Python](#tab-panel-2496)

```java
String exp = "$.email:STRING.trim()";
```

```python
exp = "$.email:STRING.trim()"
```

```rust
use aerospike::expressions::{string as str_exp, string_bin};

use aerospike::operations::string::{StringPolicy};

let exp = str_exp::trim(&StringPolicy::default(), string_bin("email".into()));
```

```csharp
using Aerospike.Client;

Expression exp = Exp.Build(

  StringExp.Trim(StringPolicy.Default, Exp.StringBin("email")));
```

```go
// Requires: import as "github.com/aerospike/aerospike-client-go/v8"

exp := as.ExpStringTrim(as.DefaultStringPolicy, as.ExpStringBin("email"))
```

```javascript
const exp = Aerospike.exp

const expression = exp.string.trim(null, exp.binStr('email'))
```

```c
as_exp_build(predexp,

  as_exp_string_trim(NULL, as_exp_bin_str("email")));
```

```java
import com.aerospike.client.exp.StringExp;

import com.aerospike.client.operation.StringPolicy;

Expression exp = Exp.build(

  StringExp.trim(StringPolicy.Default, Exp.stringBin("email")));
```

```python
from aerospike_helpers.expressions import string as str_expr

from aerospike_helpers.string_helpers import StringPolicy

exp = str_expr.Trim(StringPolicy(), bin="email").compile()
```

---

#### `string_trim_end`

`update_only` `no_fail`

```python
string_trim_end(policy, bin)
```

Description: Returns the string with trailing Unicode whitespace removed. Unlike the `trim_end` Operate API operation, the expression form yields the transformed string as a value instead of writing it back to the bin.

Arguments: | Name | Type | Description |
| --- | --- | --- |
| `policy` | `String policy` | 
Write flags for the transform. Optional, and defaults to none. With `NO_FAIL`, a failure that would abort the transform instead yields the source string unchanged, so the expression still produces a value. See [Operation flags](https://aerospike.com/docs/develop/data-types/string/operations#operation-flags) for which failures it suppresses.

 |
| `bin` | `string` | 

String bin to operate on, or any expression that evaluates to a string.

 |

Returns: `string`

Introduced: 8.2.0

Operate API operation: [`trim_end`](https://aerospike.com/docs/develop/data-types/string/operations#trim_end)

Example: Compose string expressions in query filters or `operate` read projections. Most clients take the policy first and the source string last. Go and Rust take the source string second, right after the policy.

-   [Java SDK](#tab-panel-2497)
-   [Python SDK](#tab-panel-2498)
-   [Rust](#tab-panel-2499)
-   [C#](#tab-panel-2500)
-   [Go](#tab-panel-2501)
-   [Node.js](#tab-panel-2502)
-   [C](#tab-panel-2503)
-   [Java](#tab-panel-2504)
-   [Python](#tab-panel-2505)

```java
String exp = "$.email:STRING.trimEnd()";
```

```python
exp = "$.email:STRING.trimEnd()"
```

```rust
use aerospike::expressions::{string as str_exp, string_bin};

use aerospike::operations::string::{StringPolicy};

let exp = str_exp::trim_end(&StringPolicy::default(), string_bin("email".into()));
```

```csharp
using Aerospike.Client;

Expression exp = Exp.Build(

  StringExp.TrimEnd(StringPolicy.Default, Exp.StringBin("email")));
```

```go
// Requires: import as "github.com/aerospike/aerospike-client-go/v8"

exp := as.ExpStringTrimEnd(as.DefaultStringPolicy, as.ExpStringBin("email"))
```

```javascript
const exp = Aerospike.exp

const expression = exp.string.trimEnd(null, exp.binStr('email'))
```

```c
as_exp_build(predexp,

  as_exp_string_trim_end(NULL, as_exp_bin_str("email")));
```

```java
import com.aerospike.client.exp.StringExp;

import com.aerospike.client.operation.StringPolicy;

Expression exp = Exp.build(

  StringExp.trimEnd(StringPolicy.Default, Exp.stringBin("email")));
```

```python
from aerospike_helpers.expressions import string as str_expr

from aerospike_helpers.string_helpers import StringPolicy

exp = str_expr.TrimEnd(StringPolicy(), bin="email").compile()
```

---

#### `string_trim_start`

`update_only` `no_fail`

```python
string_trim_start(policy, bin)
```

Description: Returns the string with leading Unicode whitespace removed. Unlike the `trim_start` Operate API operation, the expression form yields the transformed string as a value instead of writing it back to the bin.

Arguments: | Name | Type | Description |
| --- | --- | --- |
| `policy` | `String policy` | 
Write flags for the transform. Optional, and defaults to none. With `NO_FAIL`, a failure that would abort the transform instead yields the source string unchanged, so the expression still produces a value. See [Operation flags](https://aerospike.com/docs/develop/data-types/string/operations#operation-flags) for which failures it suppresses.

 |
| `bin` | `string` | 

String bin to operate on, or any expression that evaluates to a string.

 |

Returns: `string`

Introduced: 8.2.0

Operate API operation: [`trim_start`](https://aerospike.com/docs/develop/data-types/string/operations#trim_start)

Example: Compose string expressions in query filters or `operate` read projections. Most clients take the policy first and the source string last. Go and Rust take the source string second, right after the policy.

-   [Java SDK](#tab-panel-2506)
-   [Python SDK](#tab-panel-2507)
-   [Rust](#tab-panel-2508)
-   [C#](#tab-panel-2509)
-   [Go](#tab-panel-2510)
-   [Node.js](#tab-panel-2511)
-   [C](#tab-panel-2512)
-   [Java](#tab-panel-2513)
-   [Python](#tab-panel-2514)

```java
String exp = "$.email:STRING.trimStart()";
```

```python
exp = "$.email:STRING.trimStart()"
```

```rust
use aerospike::expressions::{string as str_exp, string_bin};

use aerospike::operations::string::{StringPolicy};

let exp = str_exp::trim_start(&StringPolicy::default(), string_bin("email".into()));
```

```csharp
using Aerospike.Client;

Expression exp = Exp.Build(

  StringExp.TrimStart(StringPolicy.Default, Exp.StringBin("email")));
```

```go
// Requires: import as "github.com/aerospike/aerospike-client-go/v8"

exp := as.ExpStringTrimStart(as.DefaultStringPolicy, as.ExpStringBin("email"))
```

```javascript
const exp = Aerospike.exp

const expression = exp.string.trimStart(null, exp.binStr('email'))
```

```c
as_exp_build(predexp,

  as_exp_string_trim_start(NULL, as_exp_bin_str("email")));
```

```java
import com.aerospike.client.exp.StringExp;

import com.aerospike.client.operation.StringPolicy;

Expression exp = Exp.build(

  StringExp.trimStart(StringPolicy.Default, Exp.stringBin("email")));
```

```python
from aerospike_helpers.expressions import string as str_expr

from aerospike_helpers.string_helpers import StringPolicy

exp = str_expr.TrimStart(StringPolicy(), bin="email").compile()
```

---

#### `string_upper`

`update_only` `no_fail`

```python
string_upper(policy, bin)
```

Description: Returns the uppercase form of a string expression. Unlike the `upper` Operate API operation, the expression form yields the transformed string as a value instead of writing it back to the bin.

Arguments: | Name | Type | Description |
| --- | --- | --- |
| `policy` | `String policy` | 
Write flags for the transform. Optional, and defaults to none. With `NO_FAIL`, a failure that would abort the transform instead yields the source string unchanged, so the expression still produces a value. See [Operation flags](https://aerospike.com/docs/develop/data-types/string/operations#operation-flags) for which failures it suppresses.

 |
| `bin` | `string` | 

String bin to operate on, or any expression that evaluates to a string.

 |

Returns: `string`

Introduced: 8.2.0

Operate API operation: [`upper`](https://aerospike.com/docs/develop/data-types/string/operations#upper)

Example: Compose string expressions in query filters or `operate` read projections. Most clients take the policy first and the source string last. Go and Rust take the source string second, right after the policy.

-   [Java SDK](#tab-panel-2515)
-   [Python SDK](#tab-panel-2516)
-   [Rust](#tab-panel-2517)
-   [C#](#tab-panel-2518)
-   [Go](#tab-panel-2519)
-   [Node.js](#tab-panel-2520)
-   [C](#tab-panel-2521)
-   [Java](#tab-panel-2522)
-   [Python](#tab-panel-2523)

```java
String exp = "$.name:STRING.upper()";
```

```python
exp = "$.name:STRING.upper()"
```

```rust
use aerospike::expressions::{string as str_exp, string_bin};

use aerospike::operations::string::{StringPolicy};

let exp = str_exp::upper(&StringPolicy::default(), string_bin("name".into()));
```

```csharp
using Aerospike.Client;

Expression exp = Exp.Build(

  StringExp.Upper(StringPolicy.Default, Exp.StringBin("name")));
```

```go
// Requires: import as "github.com/aerospike/aerospike-client-go/v8"

exp := as.ExpStringUpper(as.DefaultStringPolicy, as.ExpStringBin("name"))
```

```javascript
const exp = Aerospike.exp

const expression = exp.string.upper(null, exp.binStr('name'))
```

```c
as_exp_build(predexp,

  as_exp_string_upper(NULL, as_exp_bin_str("name")));
```

```java
import com.aerospike.client.exp.StringExp;

import com.aerospike.client.operation.StringPolicy;

Expression exp = Exp.build(

  StringExp.upper(StringPolicy.Default, Exp.stringBin("name")));
```

```python
from aerospike_helpers.expressions import string as str_expr

from aerospike_helpers.string_helpers import StringPolicy

exp = str_expr.Upper(StringPolicy(), bin="name").compile()
```

---

## Read

#### `string_b64_decode`

```python
string_b64_decode(bin)
```

Description: Decodes a base64-encoded string expression into a Blob.

Arguments: | Name | Type | Description |
| --- | --- | --- |
| `bin` | `string` | 
String bin to operate on, or any expression that evaluates to a string.

 |

Returns: `blob`

Introduced: 8.2.0

Operate API operation: [`b64_decode`](https://aerospike.com/docs/develop/data-types/string/operations#b64_decode)

Example: Compose string expressions in query filters or `operate` read projections.

-   [Java SDK](#tab-panel-2524)
-   [Python SDK](#tab-panel-2525)
-   [Rust](#tab-panel-2526)
-   [C#](#tab-panel-2527)
-   [Go](#tab-panel-2528)
-   [Node.js](#tab-panel-2529)
-   [C](#tab-panel-2530)
-   [Java](#tab-panel-2531)
-   [Python](#tab-panel-2532)

```java
String exp = "$.encoded:STRING.b64Decode()";
```

```python
exp = "$.encoded:STRING.b64Decode()"
```

```rust
use aerospike::expressions::{string as str_exp, string_bin};

let exp = str_exp::b64_decode(string_bin("encoded".into()));
```

```csharp
using Aerospike.Client;

Expression exp = Exp.Build(

  StringExp.B64Decode(Exp.StringBin("encoded")));
```

```go
// Requires: import as "github.com/aerospike/aerospike-client-go/v8"

exp := as.ExpStringB64Decode(as.ExpStringBin("encoded"))
```

```javascript
const exp = Aerospike.exp

const expression = exp.string.b64Decode(exp.binStr('encoded'))
```

```c
as_exp_build(predexp,

  as_exp_string_b64_decode(as_exp_bin_str("encoded")));
```

```java
import com.aerospike.client.exp.StringExp;

Expression exp = Exp.build(

  StringExp.b64Decode(Exp.stringBin("encoded")));
```

```python
from aerospike_helpers.expressions import string as str_expr

exp = str_expr.Base64Decode(bin="encoded").compile()
```

---

#### `string_byte_length`

```python
string_byte_length(bin)
```

Description: Returns the number of UTF-8 bytes in a string expression.

Arguments: | Name | Type | Description |
| --- | --- | --- |
| `bin` | `string` | 
String bin to operate on, or any expression that evaluates to a string.

 |

Returns: `integer`

Introduced: 8.2.0

Operate API operation: [`byte_length`](https://aerospike.com/docs/develop/data-types/string/operations#byte_length)

Example: Compose string expressions in query filters or `operate` read projections.

-   [Java SDK](#tab-panel-2533)
-   [Python SDK](#tab-panel-2534)
-   [Rust](#tab-panel-2535)
-   [C#](#tab-panel-2536)
-   [Go](#tab-panel-2537)
-   [Node.js](#tab-panel-2538)
-   [C](#tab-panel-2539)
-   [Java](#tab-panel-2540)
-   [Python](#tab-panel-2541)

```java
// byte_length is bytesLength in AEL.

String exp = "$.email:STRING.bytesLength()";
```

```python
# byte_length is bytesLength in AEL.

exp = "$.email:STRING.bytesLength()"
```

```rust
use aerospike::expressions::{string as str_exp, string_bin};

let exp = str_exp::byte_length(string_bin("email".into()));
```

```csharp
using Aerospike.Client;

Expression exp = Exp.Build(

  StringExp.ByteLength(Exp.StringBin("email")));
```

```go
// Requires: import as "github.com/aerospike/aerospike-client-go/v8"

exp := as.ExpStringByteLength(as.ExpStringBin("email"))
```

```javascript
const exp = Aerospike.exp

const expression = exp.string.byteLength(exp.binStr('email'))
```

```c
as_exp_build(predexp,

  as_exp_string_byte_length(as_exp_bin_str("email")));
```

```java
import com.aerospike.client.exp.StringExp;

Expression exp = Exp.build(

  StringExp.byteLength(Exp.stringBin("email")));
```

```python
from aerospike_helpers.expressions import string as str_expr

exp = str_expr.ByteLength(bin="email").compile()
```

---

#### `string_char_at`

```python
string_char_at(index, bin)
```

Description: Returns the single-codepoint substring at `index` from a string expression. Negative values count from the end of the string.

Arguments: | Name | Type | Description |
| --- | --- | --- |
| `index` | `integer` | 
Codepoint index. Negative values count from the end of the string, so `-1` selects the last codepoint.

 |
| `bin` | `string` | 

String bin to operate on, or any expression that evaluates to a string.

 |

Returns: `string`

Introduced: 8.2.0

Operate API operation: [`char_at`](https://aerospike.com/docs/develop/data-types/string/operations#char_at)

Example: Compose string expressions in query filters or `operate` read projections. Most clients take the operands first and the source string last. Go and Rust take the source string first.

-   [Java SDK](#tab-panel-2542)
-   [Python SDK](#tab-panel-2543)
-   [Rust](#tab-panel-2544)
-   [C#](#tab-panel-2545)
-   [Go](#tab-panel-2546)
-   [Node.js](#tab-panel-2547)
-   [C](#tab-panel-2548)
-   [Java](#tab-panel-2549)
-   [Python](#tab-panel-2550)

```java
String exp = "$.email:STRING.charAt(index: -1)";
```

```python
exp = "$.email:STRING.charAt(index: -1)"
```

```rust
use aerospike::expressions::{int_val, string as str_exp, string_bin};

let exp = str_exp::char_at(string_bin("email".into()), int_val(-1));
```

```csharp
using Aerospike.Client;

Expression exp = Exp.Build(

  StringExp.CharAt(Exp.Val(-1), Exp.StringBin("email")));
```

```go
// Requires: import as "github.com/aerospike/aerospike-client-go/v8"

exp := as.ExpStringCharAt(as.ExpStringBin("email"), as.ExpIntVal(-1))
```

```javascript
const exp = Aerospike.exp

const expression = exp.string.charAt(-1, exp.binStr('email'))
```

```c
as_exp_build(predexp,

  as_exp_string_char_at(-1, as_exp_bin_str("email")));
```

```java
import com.aerospike.client.exp.StringExp;

Expression exp = Exp.build(

  StringExp.charAt(Exp.val(-1), Exp.stringBin("email")));
```

```python
from aerospike_helpers.expressions import string as str_expr

exp = str_expr.CharAt(index=-1, bin="email").compile()
```

---

#### `string_contains`

```python
string_contains(needle, bin)
```

Description: Returns whether a string expression contains `needle`, respecting Unicode canonical equivalence.

Arguments: | Name | Type | Description |
| --- | --- | --- |
| `needle` | `string` | 
Substring to search for.

 |
| `bin` | `string` | 

String bin to operate on, or any expression that evaluates to a string.

 |

Returns: `boolean`

Introduced: 8.2.0

Operate API operation: [`contains`](https://aerospike.com/docs/develop/data-types/string/operations#contains)

Example: Compose string expressions in query filters or `operate` read projections. Most clients take the operands first and the source string last. Go and Rust take the source string first.

-   [Java SDK](#tab-panel-2551)
-   [Python SDK](#tab-panel-2552)
-   [Rust](#tab-panel-2553)
-   [C#](#tab-panel-2554)
-   [Go](#tab-panel-2555)
-   [Node.js](#tab-panel-2556)
-   [C](#tab-panel-2557)
-   [Java](#tab-panel-2558)
-   [Python](#tab-panel-2559)

```java
String exp = "$.email:STRING.contains(needle: '@company.com')";
```

```python
exp = "$.email:STRING.contains(needle: '@company.com')"
```

```rust
use aerospike::expressions::{string as str_exp, string_bin, string_val};

let exp = str_exp::contains(string_bin("email".into()), string_val("@company.com".into()));
```

```csharp
using Aerospike.Client;

Expression exp = Exp.Build(

  StringExp.Contains(Exp.Val("@company.com"), Exp.StringBin("email")));
```

```go
// Requires: import as "github.com/aerospike/aerospike-client-go/v8"

exp := as.ExpStringContains(as.ExpStringBin("email"), as.ExpStringVal("@company.com"))
```

```javascript
const exp = Aerospike.exp

const expression = exp.string.contains('@company.com', exp.binStr('email'))
```

```c
as_exp_build(predexp,

  as_exp_string_contains("@company.com", as_exp_bin_str("email")));
```

```java
import com.aerospike.client.exp.StringExp;

Expression exp = Exp.build(

  StringExp.contains(Exp.val("@company.com"), Exp.stringBin("email")));
```

```python
from aerospike_helpers.expressions import string as str_expr

exp = str_expr.Contains(needle="@company.com", bin="email").compile()
```

---

#### `string_ends_with`

```python
string_ends_with(suffix, bin)
```

Description: Returns whether a string expression ends with `suffix`.

Arguments: | Name | Type | Description |
| --- | --- | --- |
| `suffix` | `string` | 
Substring the value must end with.

 |
| `bin` | `string` | 

String bin to operate on, or any expression that evaluates to a string.

 |

Returns: `boolean`

Introduced: 8.2.0

Operate API operation: [`ends_with`](https://aerospike.com/docs/develop/data-types/string/operations#ends_with)

Example: Compose string expressions in query filters or `operate` read projections. Most clients take the operands first and the source string last. Go and Rust take the source string first.

-   [Java SDK](#tab-panel-2560)
-   [Python SDK](#tab-panel-2561)
-   [Rust](#tab-panel-2562)
-   [C#](#tab-panel-2563)
-   [Go](#tab-panel-2564)
-   [Node.js](#tab-panel-2565)
-   [C](#tab-panel-2566)
-   [Java](#tab-panel-2567)
-   [Python](#tab-panel-2568)

```java
String exp = "$.email:STRING.endsWith('.com')";
```

```python
exp = "$.email:STRING.endsWith('.com')"
```

```rust
use aerospike::expressions::{string as str_exp, string_bin, string_val};

let exp = str_exp::ends_with(string_bin("email".into()), string_val(".com".into()));
```

```csharp
using Aerospike.Client;

Expression exp = Exp.Build(

  StringExp.EndsWith(Exp.Val(".com"), Exp.StringBin("email")));
```

```go
// Requires: import as "github.com/aerospike/aerospike-client-go/v8"

exp := as.ExpStringEndsWith(as.ExpStringBin("email"), as.ExpStringVal(".com"))
```

```javascript
const exp = Aerospike.exp

const expression = exp.string.endsWith('.com', exp.binStr('email'))
```

```c
as_exp_build(predexp,

  as_exp_string_ends_with(".com", as_exp_bin_str("email")));
```

```java
import com.aerospike.client.exp.StringExp;

Expression exp = Exp.build(

  StringExp.endsWith(Exp.val(".com"), Exp.stringBin("email")));
```

```python
from aerospike_helpers.expressions import string as str_expr

exp = str_expr.EndsWith(suffix=".com", bin="email").compile()
```

---

#### `string_find`

```python
string_find(needle[, occurrence], bin)
```

Description: Returns the codepoint index of `needle` in a string expression, or `-1` if not found.

Arguments: | Name | Type | Description |
| --- | --- | --- |
| `needle` | `string` | 
Substring to search for.

 |
| `occurrence` | `integer` | 

1-based match number. Negative values count from the end of the string. Must be non-zero. Optional, and defaults to `1` (first match).

 |
| `bin` | `string` | 

String bin to operate on, or any expression that evaluates to a string.

 |

Returns: `integer`

Introduced: 8.2.0

Operate API operation: [`find`](https://aerospike.com/docs/develop/data-types/string/operations#find)

Example: Compose string expressions in query filters or `operate` read projections. Most clients take the operands first and the source string last. Go and Rust take the source string first.

-   [Java SDK](#tab-panel-2569)
-   [Python SDK](#tab-panel-2570)
-   [Rust](#tab-panel-2571)
-   [C#](#tab-panel-2572)
-   [Go](#tab-panel-2573)
-   [Node.js](#tab-panel-2574)
-   [C](#tab-panel-2575)
-   [Java](#tab-panel-2576)
-   [Python](#tab-panel-2577)

```java
String exp = "$.email:STRING.find(needle: '@', occurrence: 1)";
```

```python
exp = "$.email:STRING.find(needle: '@', occurrence: 1)"
```

```rust
use aerospike::expressions::{int_val, string as str_exp, string_bin, string_val};

let exp = str_exp::find_nth(string_bin("email".into()), string_val("@".into()), int_val(1));
```

```csharp
using Aerospike.Client;

Expression exp = Exp.Build(

  StringExp.Find(Exp.Val("@"), Exp.Val(1), Exp.StringBin("email")));
```

```go
// Requires: import as "github.com/aerospike/aerospike-client-go/v8"

exp := as.ExpStringFindNth(as.ExpStringBin("email"), as.ExpStringVal("@"),

    as.ExpIntVal(1))
```

```javascript
const exp = Aerospike.exp

const expression = exp.string.findOccurrence('@', 1, exp.binStr('email'))
```

```c
as_exp_build(predexp,

  as_exp_string_find_occurrence("@", 1, as_exp_bin_str("email")));
```

```java
import com.aerospike.client.exp.StringExp;

Expression exp = Exp.build(

  StringExp.find(Exp.val("@"), Exp.val(1), Exp.stringBin("email")));
```

```python
from aerospike_helpers.expressions import string as str_expr

exp = str_expr.Find(needle="@", occurrence=1, bin="email").compile()
```

---

#### `string_is_lower`

```python
string_is_lower(bin)
```

Description: Returns whether a string expression is lowercase: it holds no uppercase letter and at least one lowercase letter. Digits, spaces, and punctuation are ignored rather than counted against the value, so a non-empty value holding no cased letter returns `false`. An empty string returns `true`.

Arguments: | Name | Type | Description |
| --- | --- | --- |
| `bin` | `string` | 
String bin to operate on, or any expression that evaluates to a string.

 |

Returns: `boolean`

Introduced: 8.2.0

Operate API operation: [`is_lower`](https://aerospike.com/docs/develop/data-types/string/operations#is_lower)

Example: Compose string expressions in query filters or `operate` read projections.

-   [Java SDK](#tab-panel-2578)
-   [Python SDK](#tab-panel-2579)
-   [Rust](#tab-panel-2580)
-   [C#](#tab-panel-2581)
-   [Go](#tab-panel-2582)
-   [Node.js](#tab-panel-2583)
-   [C](#tab-panel-2584)
-   [Java](#tab-panel-2585)
-   [Python](#tab-panel-2586)

```java
String exp = "$.code:STRING.isLower()";
```

```python
exp = "$.code:STRING.isLower()"
```

```rust
use aerospike::expressions::{string as str_exp, string_bin};

let exp = str_exp::is_lower(string_bin("code".into()));
```

```csharp
using Aerospike.Client;

Expression exp = Exp.Build(

  StringExp.IsLower(Exp.StringBin("code")));
```

```go
// Requires: import as "github.com/aerospike/aerospike-client-go/v8"

exp := as.ExpStringIsLower(as.ExpStringBin("code"))
```

```javascript
const exp = Aerospike.exp

const expression = exp.string.isLower(exp.binStr('code'))
```

```c
as_exp_build(predexp,

  as_exp_string_is_lower(as_exp_bin_str("code")));
```

```java
import com.aerospike.client.exp.StringExp;

Expression exp = Exp.build(

  StringExp.isLower(Exp.stringBin("code")));
```

```python
from aerospike_helpers.expressions import string as str_expr

exp = str_expr.IsLower(bin="code").compile()
```

---

#### `string_is_numeric`

```python
string_is_numeric([numeric_type, ]bin)
```

Description: Returns whether a string expression belongs to the requested numeric class.

Arguments: | Name | Type | Description |
| --- | --- | --- |
| `numeric_type` | `integer literal` | 
Numeric class to test for: `0` = ANY (int-class or float-class, the default), `1` = INT (optional sign then digits only, must fit `int64`), `2` = FLOAT (must contain a literal `.` followed by at least one digit, and must fit `double`). Constants are `NumericType` in Python, `StringNumericType` in Java, and `as_string_numeric_type` in C. Optional, and defaults to `0` (ANY).

 |
| `bin` | `string` | 

String bin to operate on, or any expression that evaluates to a string.

 |

Returns: `boolean`

Introduced: 8.2.0

Operate API operation: [`is_numeric`](https://aerospike.com/docs/develop/data-types/string/operations#is_numeric)

Example: Compose string expressions in query filters or `operate` read projections. Most clients take the operand first and the source string last, while Go and Rust take the source string first. Float-class matching requires a literal `.`, so scientific-notation literals such as `1e5` match none of the three classes, including ANY.

-   [Java SDK](#tab-panel-2587)
-   [Python SDK](#tab-panel-2588)
-   [Rust](#tab-panel-2589)
-   [C#](#tab-panel-2590)
-   [Go](#tab-panel-2591)
-   [Node.js](#tab-panel-2592)
-   [C](#tab-panel-2593)
-   [Java](#tab-panel-2594)
-   [Python](#tab-panel-2595)

```java
String exp = "$.amount:STRING.isNumeric()";
```

```python
exp = "$.amount:STRING.isNumeric()"
```

```rust
use aerospike::expressions::{string as str_exp, string_bin};

use aerospike::operations::string::{StringNumericType};

let exp = str_exp::is_numeric_typed(string_bin("amount".into()), StringNumericType::Any);
```

```csharp
using Aerospike.Client;

Expression exp = Exp.Build(

  StringExp.IsNumeric(StringNumericType.ANY, Exp.StringBin("amount")));
```

```go
// Requires: import as "github.com/aerospike/aerospike-client-go/v8"

exp := as.ExpStringIsNumericTyped(as.ExpStringBin("amount"), as.StringNumericAny)
```

```javascript
const exp = Aerospike.exp

const expression = exp.string.isNumeric(exp.binStr('amount'))
```

```c
as_exp_build(predexp,

  as_exp_string_is_numeric_type(AS_STRING_NUMERIC_ANY, as_exp_bin_str("amount")));
```

```java
import com.aerospike.client.exp.StringExp;

import com.aerospike.client.operation.StringNumericType;

Expression exp = Exp.build(

  StringExp.isNumeric(StringNumericType.ANY, Exp.stringBin("amount")));
```

```python
from aerospike_helpers.expressions import string as str_expr

from aerospike_helpers.string_helpers import NumericType

exp = str_expr.IsNumeric(numeric_type=NumericType.ANY, bin="amount").compile()
```

---

#### `string_is_upper`

```python
string_is_upper(bin)
```

Description: Returns whether a string expression is uppercase: it holds no lowercase letter and at least one uppercase letter. Digits, spaces, and punctuation are ignored rather than counted against the value, so a non-empty value holding no cased letter returns `false`. An empty string returns `true`.

Arguments: | Name | Type | Description |
| --- | --- | --- |
| `bin` | `string` | 
String bin to operate on, or any expression that evaluates to a string.

 |

Returns: `boolean`

Introduced: 8.2.0

Operate API operation: [`is_upper`](https://aerospike.com/docs/develop/data-types/string/operations#is_upper)

Example: Compose string expressions in query filters or `operate` read projections.

-   [Java SDK](#tab-panel-2596)
-   [Python SDK](#tab-panel-2597)
-   [Rust](#tab-panel-2598)
-   [C#](#tab-panel-2599)
-   [Go](#tab-panel-2600)
-   [Node.js](#tab-panel-2601)
-   [C](#tab-panel-2602)
-   [Java](#tab-panel-2603)
-   [Python](#tab-panel-2604)

```java
String exp = "$.code:STRING.isUpper()";
```

```python
exp = "$.code:STRING.isUpper()"
```

```rust
use aerospike::expressions::{string as str_exp, string_bin};

let exp = str_exp::is_upper(string_bin("code".into()));
```

```csharp
using Aerospike.Client;

Expression exp = Exp.Build(

  StringExp.IsUpper(Exp.StringBin("code")));
```

```go
// Requires: import as "github.com/aerospike/aerospike-client-go/v8"

exp := as.ExpStringIsUpper(as.ExpStringBin("code"))
```

```javascript
const exp = Aerospike.exp

const expression = exp.string.isUpper(exp.binStr('code'))
```

```c
as_exp_build(predexp,

  as_exp_string_is_upper(as_exp_bin_str("code")));
```

```java
import com.aerospike.client.exp.StringExp;

Expression exp = Exp.build(

  StringExp.isUpper(Exp.stringBin("code")));
```

```python
from aerospike_helpers.expressions import string as str_expr

exp = str_expr.IsUpper(bin="code").compile()
```

---

#### `string_regex_compare`

```python
string_regex_compare(pattern, regex_flags, bin)
```

Description: Returns whether a string expression matches `pattern`, using ICU regular expression syntax. Prefer over legacy [cmp\_regex](https://aerospike.com/develop/expressions/comparison#cmp_regex).

Arguments: | Name | Type | Description |
| --- | --- | --- |
| `pattern` | `string` | 
ICU regular expression to match. It is evaluated per record, so it can come from a bin or from another expression, not only from a constant.

 |
| `regex_flags` | `integer literal` | 

Bit field of regex regex\_flags on the six client-builder tabs, combinable with bitwise OR; `GLOBAL` is not valid here. The two SDK tabs take AEL text, which has no regex\_flags argument at all — regex\_flags there are letters appended to the regex literal, as in `/^555.*/i`. For the values, their effects, and the AEL letters, see [Regex flags](https://aerospike.com/develop/data-types/string/regex-syntax#flags).

 |
| `bin` | `string` | 

String bin to operate on, or any expression that evaluates to a string.

 |

Returns: `boolean`

Introduced: 8.2.0

Operate API operation: [`regex_compare`](https://aerospike.com/docs/develop/data-types/string/operations#regex_compare)

Example: Compose string expressions in query filters or `operate` read projections. Most clients take the operands first and the source string last. Python is the exception here, taking the source second, as in `RegexCompare(pattern, bin, regex_flags)`.

-   [Java SDK](#tab-panel-2605)
-   [Python SDK](#tab-panel-2606)
-   [Rust](#tab-panel-2607)
-   [C#](#tab-panel-2608)
-   [Go](#tab-panel-2609)
-   [Node.js](#tab-panel-2610)
-   [C](#tab-panel-2611)
-   [Java](#tab-panel-2612)
-   [Python](#tab-panel-2613)

```java
// AEL has no regex_compare function; it matches with =~ and a regex literal.

String exp = "$.phone:STRING =~ /^555.*/";
```

```python
# AEL has no regex_compare function; it matches with =~ and a regex literal.

exp = "$.phone:STRING =~ /^555.*/"
```

```rust
use aerospike::expressions::{string as str_exp, string_bin, string_val};

use aerospike::operations::string::{StringRegexFlags};

let exp = str_exp::regex_compare_with_flags(string_bin("phone".into()),

    string_val("^555.*".into()), StringRegexFlags::DEFAULT);
```

```csharp
using Aerospike.Client;

Expression exp = Exp.Build(

  StringExp.RegexCompare(Exp.Val("^555.*"), StringRegexFlags.DEFAULT,

    Exp.StringBin("phone")));
```

```go
// Requires: import as "github.com/aerospike/aerospike-client-go/v8"

exp := as.ExpStringRegexCompareWithFlags(as.ExpStringBin("phone"),

    as.ExpStringVal("^555.*"), as.StringRegexDefault)
```

```javascript
const exp = Aerospike.exp

const expression = exp.string.regexCompare('^555.*', exp.binStr('phone'))
```

```c
as_exp_build(predexp,

  as_exp_string_regex_compare_flags("^555.*", AS_STRING_REGEX_FLAGS_NONE,

    as_exp_bin_str("phone")));
```

```java
import com.aerospike.client.exp.StringExp;

import com.aerospike.client.operation.StringRegexFlags;

Expression exp = Exp.build(

  StringExp.regexCompare(Exp.val("^555.*"), StringRegexFlags.DEFAULT,

    Exp.stringBin("phone")));
```

```python
from aerospike_helpers.expressions import string as str_expr

from aerospike_helpers.string_helpers import RegexFlags

exp = str_expr.RegexCompare(

    pattern="^555.*", bin="phone", regex_flags=RegexFlags.DEFAULT

).compile()
```

---

#### `string_split`

```python
string_split([separator, ]bin)
```

Description: Returns a list of strings by splitting a string expression on `separator`.

Arguments: | Name | Type | Description |
| --- | --- | --- |
| `separator` | `string` | 
Delimiter string. Optional. When omitted, the string is split into one element per Unicode codepoint rather than returned unsplit.

 |
| `bin` | `string` | 

String bin to operate on, or any expression that evaluates to a string.

 |

Returns: `list`

Introduced: 8.2.0

Operate API operation: [`split`](https://aerospike.com/docs/develop/data-types/string/operations#split)

Example: Compose string expressions in query filters or `operate` read projections. Most clients take the operands first and the source string last. Go and Rust take the source string first.

-   [Java SDK](#tab-panel-2614)
-   [Python SDK](#tab-panel-2615)
-   [Rust](#tab-panel-2616)
-   [C#](#tab-panel-2617)
-   [Go](#tab-panel-2618)
-   [Node.js](#tab-panel-2619)
-   [C](#tab-panel-2620)
-   [Java](#tab-panel-2621)
-   [Python](#tab-panel-2622)

```java
String exp = "$.tags:STRING.split(',')";
```

```python
exp = "$.tags:STRING.split(',')"
```

```rust
use aerospike::expressions::{string as str_exp, string_bin, string_val};

let exp = str_exp::split_by_separator(string_bin("tags".into()), string_val(",".into()));
```

```csharp
using Aerospike.Client;

Expression exp = Exp.Build(

  StringExp.Split(Exp.Val(","), Exp.StringBin("tags")));
```

```go
// Requires: import as "github.com/aerospike/aerospike-client-go/v8"

exp := as.ExpStringSplitBySeparator(as.ExpStringBin("tags"), as.ExpStringVal(","))
```

```javascript
const exp = Aerospike.exp

const expression = exp.string.splitSeparator(',', exp.binStr('tags'))
```

```c
as_exp_build(predexp,

  as_exp_string_split_separator(",", as_exp_bin_str("tags")));
```

```java
import com.aerospike.client.exp.StringExp;

Expression exp = Exp.build(

  StringExp.split(Exp.val(","), Exp.stringBin("tags")));
```

```python
from aerospike_helpers.expressions import string as str_expr

exp = str_expr.SplitSeparator(separator=",", bin="tags").compile()
```

---

#### `string_starts_with`

```python
string_starts_with(prefix, bin)
```

Description: Returns whether a string expression starts with `prefix`.

Arguments: | Name | Type | Description |
| --- | --- | --- |
| `prefix` | `string` | 
Substring the value must begin with.

 |
| `bin` | `string` | 

String bin to operate on, or any expression that evaluates to a string.

 |

Returns: `boolean`

Introduced: 8.2.0

Operate API operation: [`starts_with`](https://aerospike.com/docs/develop/data-types/string/operations#starts_with)

Example: Compose string expressions in query filters or `operate` read projections. Most clients take the operands first and the source string last. Go and Rust take the source string first.

-   [Java SDK](#tab-panel-2623)
-   [Python SDK](#tab-panel-2624)
-   [Rust](#tab-panel-2625)
-   [C#](#tab-panel-2626)
-   [Go](#tab-panel-2627)
-   [Node.js](#tab-panel-2628)
-   [C](#tab-panel-2629)
-   [Java](#tab-panel-2630)
-   [Python](#tab-panel-2631)

```java
String exp = "$.sku:STRING.startsWith('A-')";
```

```python
exp = "$.sku:STRING.startsWith('A-')"
```

```rust
use aerospike::expressions::{string as str_exp, string_bin, string_val};

let exp = str_exp::starts_with(string_bin("sku".into()), string_val("A-".into()));
```

```csharp
using Aerospike.Client;

Expression exp = Exp.Build(

  StringExp.StartsWith(Exp.Val("A-"), Exp.StringBin("sku")));
```

```go
// Requires: import as "github.com/aerospike/aerospike-client-go/v8"

exp := as.ExpStringStartsWith(as.ExpStringBin("sku"), as.ExpStringVal("A-"))
```

```javascript
const exp = Aerospike.exp

const expression = exp.string.startsWith('A-', exp.binStr('sku'))
```

```c
as_exp_build(predexp,

  as_exp_string_starts_with("A-", as_exp_bin_str("sku")));
```

```java
import com.aerospike.client.exp.StringExp;

Expression exp = Exp.build(

  StringExp.startsWith(Exp.val("A-"), Exp.stringBin("sku")));
```

```python
from aerospike_helpers.expressions import string as str_expr

exp = str_expr.StartsWith(prefix="A-", bin="sku").compile()
```

---

#### `string_strlen`

```python
string_strlen(bin)
```

Description: Returns the codepoint length of a string expression.

Arguments: | Name | Type | Description |
| --- | --- | --- |
| `bin` | `string` | 
String bin to operate on, or any expression that evaluates to a string.

 |

Returns: `integer`

Introduced: 8.2.0

Operate API operation: [`strlen`](https://aerospike.com/docs/develop/data-types/string/operations#strlen)

Example: Compose string expressions in query filters or `operate` read projections.

-   [Java SDK](#tab-panel-2632)
-   [Python SDK](#tab-panel-2633)
-   [Rust](#tab-panel-2634)
-   [C#](#tab-panel-2635)
-   [Go](#tab-panel-2636)
-   [Node.js](#tab-panel-2637)
-   [C](#tab-panel-2638)
-   [Java](#tab-panel-2639)
-   [Python](#tab-panel-2640)

```java
String exp = "$.name:STRING.strlen()";
```

```python
exp = "$.name:STRING.strlen()"
```

```rust
use aerospike::expressions::{string as str_exp, string_bin};

let exp = str_exp::strlen(string_bin("name".into()));
```

```csharp
using Aerospike.Client;

Expression exp = Exp.Build(

  StringExp.Strlen(Exp.StringBin("name")));
```

```go
// Requires: import as "github.com/aerospike/aerospike-client-go/v8"

exp := as.ExpStringLen(as.ExpStringBin("name"))
```

```javascript
const exp = Aerospike.exp

const expression = exp.string.strlen(exp.binStr('name'))
```

```c
as_exp_build(predexp,

  as_exp_string_strlen(as_exp_bin_str("name")));
```

```java
import com.aerospike.client.exp.StringExp;

Expression exp = Exp.build(

  StringExp.strlen(Exp.stringBin("name")));
```

```python
from aerospike_helpers.expressions import string as str_expr

exp = str_expr.StrLen(bin="name").compile()
```

---

#### `string_substr`

```python
string_substr(from[, to], bin)
```

Description: Returns a substring by codepoint range from a string expression.

Arguments: | Name | Type | Description |
| --- | --- | --- |
| `from` | `integer` | 
Start codepoint index (inclusive). Negative values count from the end of the string. Out-of-range values are clamped to `[0, length]`.

 |
| `to` | `integer` | 

End codepoint index (exclusive). Negative values count from the end of the string. Out-of-range values are clamped to `[0, length]`. Optional, and defaults to the string’s codepoint length, returning the substring from `from` to the end of the string.

 |
| `bin` | `string` | 

String bin to operate on, or any expression that evaluates to a string.

 |

Returns: `string`

Introduced: 8.2.0

Operate API operation: [`substr`](https://aerospike.com/docs/develop/data-types/string/operations#substr)

Example: Compose string expressions in query filters or `operate` read projections. Most clients take the operands first and the source string last. Go and Rust take the source string first.

-   [Java SDK](#tab-panel-2641)
-   [Python SDK](#tab-panel-2642)
-   [Rust](#tab-panel-2643)
-   [C#](#tab-panel-2644)
-   [Go](#tab-panel-2645)
-   [Node.js](#tab-panel-2646)
-   [C](#tab-panel-2647)
-   [Java](#tab-panel-2648)
-   [Python](#tab-panel-2649)

```java
String exp = "$.email:STRING.substr(from: 0, to: 10)";
```

```python
exp = "$.email:STRING.substr(from: 0, to: 10)"
```

```rust
use aerospike::expressions::{int_val, string as str_exp, string_bin};

let exp = str_exp::substr_range(string_bin("email".into()), int_val(0), int_val(10));
```

```csharp
using Aerospike.Client;

Expression exp = Exp.Build(

  StringExp.Substr(Exp.Val(0), Exp.Val(10), Exp.StringBin("email")));
```

```go
// Requires: import as "github.com/aerospike/aerospike-client-go/v8"

exp := as.ExpStringSubstr(as.ExpStringBin("email"), as.ExpIntVal(0), as.ExpIntVal(10))
```

```javascript
const exp = Aerospike.exp

const expression = exp.string.substr(0, 10, exp.binStr('email'))
```

```c
as_exp_build(predexp,

  as_exp_string_substr_range(0, 10, as_exp_bin_str("email")));
```

```java
import com.aerospike.client.exp.StringExp;

Expression exp = Exp.build(

  StringExp.substr(Exp.val(0), Exp.val(10), Exp.stringBin("email")));
```

```python
from aerospike_helpers.expressions import string as str_expr

exp = str_expr.SubStrRange(start=0, end=10, bin="email").compile()
```

---

#### `string_to_blob`

```python
string_to_blob(bin)
```

Description: Returns the UTF-8 bytes of a string expression as a Blob.

Arguments: | Name | Type | Description |
| --- | --- | --- |
| `bin` | `string` | 
String bin to operate on, or any expression that evaluates to a string.

 |

Returns: `blob`

Introduced: 8.2.0

Operate API operation: [`to_blob`](https://aerospike.com/docs/develop/data-types/string/operations#to_blob)

Example: Compose string expressions in query filters or `operate` read projections.

-   [Java SDK](#tab-panel-2650)
-   [Python SDK](#tab-panel-2651)
-   [Rust](#tab-panel-2652)
-   [C#](#tab-panel-2653)
-   [Go](#tab-panel-2654)
-   [Node.js](#tab-panel-2655)
-   [C](#tab-panel-2656)
-   [Java](#tab-panel-2657)
-   [Python](#tab-panel-2658)

```java
String exp = "$.payload:STRING.toBlob()";
```

```python
exp = "$.payload:STRING.toBlob()"
```

```rust
use aerospike::expressions::{string as str_exp, string_bin};

let exp = str_exp::to_blob(string_bin("payload".into()));
```

```csharp
using Aerospike.Client;

Expression exp = Exp.Build(

  StringExp.ToBlob(Exp.StringBin("payload")));
```

```go
// Requires: import as "github.com/aerospike/aerospike-client-go/v8"

exp := as.ExpStringToBlob(as.ExpStringBin("payload"))
```

```javascript
const exp = Aerospike.exp

const expression = exp.string.toBlob(exp.binStr('payload'))
```

```c
as_exp_build(predexp,

  as_exp_string_to_blob(as_exp_bin_str("payload")));
```

```java
import com.aerospike.client.exp.StringExp;

Expression exp = Exp.build(

  StringExp.toBlob(Exp.stringBin("payload")));
```

```python
from aerospike_helpers.expressions import string as str_expr

exp = str_expr.ToBlob(bin="payload").compile()
```

---

#### `string_to_double`

```python
string_to_double(bin)
```

Description: Parses a string expression as a float. Supports scientific notation.

Arguments: | Name | Type | Description |
| --- | --- | --- |
| `bin` | `string` | 
String bin to operate on, or any expression that evaluates to a string.

 |

Returns: `float`

Introduced: 8.2.0

Operate API operation: [`to_double`](https://aerospike.com/docs/develop/data-types/string/operations#to_double)

Example: Compose string expressions in query filters or `operate` read projections.

-   [Java SDK](#tab-panel-2659)
-   [Python SDK](#tab-panel-2660)
-   [Rust](#tab-panel-2661)
-   [C#](#tab-panel-2662)
-   [Go](#tab-panel-2663)
-   [Node.js](#tab-panel-2664)
-   [C](#tab-panel-2665)
-   [Java](#tab-panel-2666)
-   [Python](#tab-panel-2667)

```java
// to_double is toFloat in AEL.

String exp = "$.rate:STRING.toFloat()";
```

```python
# to_double is toFloat in AEL.

exp = "$.rate:STRING.toFloat()"
```

```rust
use aerospike::expressions::{string as str_exp, string_bin};

let exp = str_exp::to_double(string_bin("rate".into()));
```

```csharp
using Aerospike.Client;

Expression exp = Exp.Build(

  StringExp.ToDouble(Exp.StringBin("rate")));
```

```go
// Requires: import as "github.com/aerospike/aerospike-client-go/v8"

exp := as.ExpStringToDouble(as.ExpStringBin("rate"))
```

```javascript
const exp = Aerospike.exp

const expression = exp.string.toDouble(exp.binStr('rate'))
```

```c
as_exp_build(predexp,

  as_exp_string_to_double(as_exp_bin_str("rate")));
```

```java
import com.aerospike.client.exp.StringExp;

Expression exp = Exp.build(

  StringExp.toDouble(Exp.stringBin("rate")));
```

```python
from aerospike_helpers.expressions import string as str_expr

exp = str_expr.ToDouble(bin="rate").compile()
```

---

#### `string_to_integer`

```python
string_to_integer(bin)
```

Description: Parses a string expression as a signed integer.

Arguments: | Name | Type | Description |
| --- | --- | --- |
| `bin` | `string` | 
String bin to operate on, or any expression that evaluates to a string.

 |

Returns: `integer`

Introduced: 8.2.0

Operate API operation: [`to_integer`](https://aerospike.com/docs/develop/data-types/string/operations#to_integer)

Example: Compose string expressions in query filters or `operate` read projections.

-   [Java SDK](#tab-panel-2668)
-   [Python SDK](#tab-panel-2669)
-   [Rust](#tab-panel-2670)
-   [C#](#tab-panel-2671)
-   [Go](#tab-panel-2672)
-   [Node.js](#tab-panel-2673)
-   [C](#tab-panel-2674)
-   [Java](#tab-panel-2675)
-   [Python](#tab-panel-2676)

```java
// to_integer is toInt in AEL.

String exp = "$.count:STRING.toInt()";
```

```python
# to_integer is toInt in AEL.

exp = "$.count:STRING.toInt()"
```

```rust
use aerospike::expressions::{string as str_exp, string_bin};

let exp = str_exp::to_integer(string_bin("count".into()));
```

```csharp
using Aerospike.Client;

Expression exp = Exp.Build(

  StringExp.ToInteger(Exp.StringBin("count")));
```

```go
// Requires: import as "github.com/aerospike/aerospike-client-go/v8"

exp := as.ExpStringToInteger(as.ExpStringBin("count"))
```

```javascript
const exp = Aerospike.exp

const expression = exp.string.toInteger(exp.binStr('count'))
```

```c
as_exp_build(predexp,

  as_exp_string_to_integer(as_exp_bin_str("count")));
```

```java
import com.aerospike.client.exp.StringExp;

Expression exp = Exp.build(

  StringExp.toInteger(Exp.stringBin("count")));
```

```python
from aerospike_helpers.expressions import string as str_expr

exp = str_expr.ToInteger(bin="count").compile()
```

---

## Type conversion

#### `to_string`

```python
to_string(value)
```

Description: Converts an integer, float, boolean, blob, or string expression to its string representation. Unlike the other entries on this page, `to_string` is a standalone expression operator rather than a member of the string expression module, which is why each client spells it without the module prefix.

Arguments: | Name | Type | Description |
| --- | --- | --- |
| `value` | `any` | 
Integer, float, boolean, blob, or string expression to convert.

 |

Returns: `string`

Introduced: 8.2.0

Operate API operation: [`to_string`](https://aerospike.com/docs/develop/data-types/string/operations#to_string)

Example: Compose string expressions in query filters or `operate` read projections.

-   [Java SDK](#tab-panel-2677)
-   [Python SDK](#tab-panel-2678)
-   [Rust](#tab-panel-2679)
-   [C#](#tab-panel-2680)
-   [Go](#tab-panel-2681)
-   [Node.js](#tab-panel-2682)
-   [C](#tab-panel-2683)
-   [Java](#tab-panel-2684)
-   [Python](#tab-panel-2685)

```java
// Pin the receiver type: toString formats whatever the bin holds.

String exp = "$.numbin:INT.toString()";
```

```python
# Pin the receiver type: toString formats whatever the bin holds.

exp = "$.numbin:INT.toString()"
```

```rust
use aerospike::expressions::{int_bin, string as str_exp};

let exp = str_exp::to_string(int_bin("numbin".into()));
```

```csharp
using Aerospike.Client;

Expression exp = Exp.Build(

  StringExp.ToString(Exp.IntBin("numbin")));
```

```go
// Requires: import as "github.com/aerospike/aerospike-client-go/v8"

exp := as.ExpStringToString(as.ExpIntBin("numbin"))
```

```javascript
const exp = Aerospike.exp

const expression = exp.string.toString(exp.binInt('numbin'))
```

```c
as_exp_build(predexp,

  as_exp_to_string(as_exp_bin_int("numbin")));
```

```java
import com.aerospike.client.exp.StringExp;

Expression exp = Exp.build(

  StringExp.toString(Exp.intBin("numbin")));
```

```python
from aerospike_helpers.expressions import string as str_expr

from aerospike_helpers.expressions import IntBin

exp = str_expr.ToString(bin=IntBin("numbin")).compile()
```

---