> For the complete documentation index, see [llms.txt](https://docs.zama.org/tfhe-rs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.zama.org/tfhe-rs/fhe-computation/operations/string-operations.md).

# String operations

This document details the string operations supported by **TFHE-rs**.

| clear name                                                                                                     | fhe name         | first input type | second input type                              | third input type                               |
| -------------------------------------------------------------------------------------------------------------- | ---------------- | ---------------- | ---------------------------------------------- | ---------------------------------------------- |
| [eq](https://doc.rust-lang.org/stable/std/primitive.str.html#method.eq)                                        | eq               | FheAsciiString   | FheAsciiString or ClearString                  |                                                |
| [ne](https://doc.rust-lang.org/stable/std/primitive.str.html#method.ne)                                        | ne               | FheAsciiString   | FheAsciiString or ClearString                  |                                                |
| [le](https://doc.rust-lang.org/stable/std/primitive.str.html#method.le)                                        | le               | FheAsciiString   | FheAsciiString or ClearString                  |                                                |
| [ge](https://doc.rust-lang.org/stable/std/primitive.str.html#method.ge)                                        | ge               | FheAsciiString   | FheAsciiString or ClearString                  |                                                |
| [lt](https://doc.rust-lang.org/stable/std/primitive.str.html#method.lt)                                        | lt               | FheAsciiString   | FheAsciiString or ClearString                  |                                                |
| [gt](https://doc.rust-lang.org/stable/std/primitive.str.html#method.gt)                                        | gt               | FheAsciiString   | FheAsciiString or ClearString                  |                                                |
| [len](https://doc.rust-lang.org/stable/std/primitive.str.html#method.len)                                      | len              | FheAsciiString   |                                                |                                                |
| [is\_empty](https://doc.rust-lang.org/stable/std/primitive.str.html#method.is_empty)                           | is\_empty        | FheAsciiString   |                                                |                                                |
| [eq\_ignore\_ascii\_case](https://doc.rust-lang.org/stable/std/primitive.str.html#method.eq_ignore_ascii_case) | eq\_ignore\_case | FheAsciiString   | FheAsciiString or ClearString                  |                                                |
| [to\_lowercase](https://doc.rust-lang.org/stable/std/primitive.str.html#method.to_lowercase)                   | to\_lowercase    | FheAsciiString   |                                                |                                                |
| [to\_uppercase](https://doc.rust-lang.org/stable/std/primitive.str.html#method.to_uppercase)                   | to\_uppercase    | FheAsciiString   |                                                |                                                |
| [contains](https://doc.rust-lang.org/stable/std/primitive.str.html#method.contains)                            | contains         | FheAsciiString   | FheAsciiString or ClearString                  |                                                |
| [ends\_with](https://doc.rust-lang.org/stable/std/primitive.str.html#method.ends_with)                         | ends\_with       | FheAsciiString   | FheAsciiString or ClearString                  |                                                |
| [starts\_with](https://doc.rust-lang.org/stable/std/primitive.str.html#method.starts_with)                     | starts\_with     | FheAsciiString   | FheAsciiString or ClearString                  |                                                |
| [find](https://doc.rust-lang.org/stable/std/primitive.str.html#method.find)                                    | find             | FheAsciiString   | FheAsciiString or ClearString                  |                                                |
| [rfind](https://doc.rust-lang.org/stable/std/primitive.str.html#method.rfind)                                  | rfind            | FheAsciiString   | FheAsciiString or ClearString                  |                                                |
| [strip\_prefix](https://doc.rust-lang.org/stable/std/primitive.str.html#method.strip_prefix)                   | strip\_prefix    | FheAsciiString   | FheAsciiString or ClearString                  |                                                |
| [strip\_suffix](https://doc.rust-lang.org/stable/std/primitive.str.html#method.strip_suffix)                   | strip\_suffix    | FheAsciiString   | FheAsciiString or ClearString                  |                                                |
| [concat](https://doc.rust-lang.org/stable/std/primitive.str.html#method.concat)                                | concat           | FheAsciiString   | FheAsciiString                                 |                                                |
| [repeat](https://doc.rust-lang.org/stable/std/primitive.str.html#method.repeat)                                | repeat           | FheAsciiString   | u16 or u32 or i32 or usize or (FheUint16, u16) |                                                |
| [trim\_end](https://doc.rust-lang.org/stable/std/primitive.str.html#method.trim_end)                           | trim\_end        | FheAsciiString   |                                                |                                                |
| [trim\_start](https://doc.rust-lang.org/stable/std/primitive.str.html#method.trim_start)                       | trim\_start      | FheAsciiString   |                                                |                                                |
| [trim](https://doc.rust-lang.org/stable/std/primitive.str.html#method.trim)                                    | trim             | FheAsciiString   |                                                |                                                |
| [replace](https://doc.rust-lang.org/stable/std/primitive.str.html#method.replace)                              | replace          | FheAsciiString   | FheAsciiString                                 |                                                |
| [replacen](https://doc.rust-lang.org/stable/std/primitive.str.html#method.replacen)                            | replacen         | FheAsciiString   | FheAsciiString or ClearString                  | u16 or u32 or i32 or usize or (FheUint16, u16) |

The following example shows how to perform string operations:

```rust
use tfhe::prelude::*;
use tfhe::{
    generate_keys, set_server_key, ConfigBuilder, FheAsciiString,
};
    
fn main() -> Result<(), Box<dyn std::error::Error>> {
    
    let config = ConfigBuilder::default().build();
    let (client_key, server_key) = generate_keys(config);
    set_server_key(server_key);
    
    let string1 = FheAsciiString::try_encrypt("tfhe-RS", &client_key).unwrap();
    let string2 = FheAsciiString::try_encrypt("TFHE-rs", &client_key).unwrap();
    let is_eq = string1.eq_ignore_case(&string2);

    assert!(is_eq.decrypt(&client_key));

    Ok(())
}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.zama.org/tfhe-rs/fhe-computation/operations/string-operations.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
