> For the complete documentation index, see [llms.txt](https://docs.kognitos.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.kognitos.com/legacy/legacy-experience/automation-areas/text/removal/remove-text-using-substrings.md).

# Remove Text Using Substrings

## Overview

This operation allows you to edit a text by specifying a piece of text ("a substring") to remove. You can optionally define the strategy to remove the substring's first, last, or all occurrences in the larger text.

## Syntax

```
the text1 is "{text1 value}"
the text2 is "{text2 value}"
remove the text2 from the text1
```

#### Optional: Specifying a Remove Strategy

Optionally, you can specify a **remove strategy** using the **where** keyword. This specifies which occurrences of the second text to remove:

```
the text1 is "{text1 value}"
the text2 is "{text2 value}"
remove the text2 from the text1 where
 the remove strategy is "{strategy}"
```

## Data

The table below lists the names of the data elements in this operation and indicates which can be renamed in the syntax.

| Data Name           | Can Be Renamed |
| ------------------- | -------------- |
| the text1           | Yes            |
| the text2           | Yes            |
| the remove strategy | No             |

## Parameters

**Parameters** are placeholders for data. Refer to the table below for details on each parameter in this operation. In the syntax, replace parameters with your own values.

| `text1 value` | The target text.                                                                                                                                                                                                                                                | "The dog barked." | Yes      |
| ------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------- | -------- |
| `text2 value` | The text to be removed from the target string.                                                                                                                                                                                                                  | "dog"             | Yes      |
| `strategy`    | <p>The removal strategy. There is no default. Accepted values:</p><ul><li><strong>first</strong> - Removes the first occurrence.</li><li><strong>last</strong> - Removes the last occurrence.</li><li><strong>all</strong> - Removes all occurrences.</li></ul> | "all"             | Optional |

## Examples

### 1. Remove all occurrences

{% tabs %}
{% tab title="Automation" %}

```
the input text is "The quick brown fox jumps over the lazy dog. The dog barked."
the focus word is "dog"
remove the focus word from the input text where
  the remove strategy is "all"
```

{% endtab %}

{% tab title="Results" %}

```
The quick brown fox jumps over the lazy . The barked.
```

{% endtab %}
{% endtabs %}

### 2. Remove the first occurrence

{% tabs %}
{% tab title="Automation" %}

```
the input text is "The quick brown fox jumps over the lazy dog. The dog barked."
the focus word is "dog"
remove the focus word from the input text where
  the remove strategy is "first"
```

{% endtab %}

{% tab title="Results" %}

```
The quick brown fox jumps over the lazy . The dog barked.
```

{% endtab %}
{% endtabs %}

### 3. Remove the last occurrence

{% tabs %}
{% tab title="Automation" %}

```
the input text is "The quick brown fox jumps over the lazy dog. The dog barked."
the focus word is "dog"
remove the focus word from the input text where
  the remove strategy is "last"
```

{% endtab %}

{% tab title="Results" %}

```
The quick brown fox jumps over the lazy dog. The barked.
```

{% endtab %}
{% endtabs %}

### 4. No removal strategy specified

{% tabs %}
{% tab title="Automation" %}

```
the input text is "The quick brown fox jumps over the lazy dog. The dog barked."
the focus word is "dog"
remove the focus word from the input text
```

{% endtab %}
{% endtabs %}

This will **Raise a Question** and prompt you to choose which value to remove.

> Multiple: "dog"s in: "The quick brown fox jumps over the lazy dog. The dog barked." Which one do you want to remove?


---

# 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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.kognitos.com/legacy/legacy-experience/automation-areas/text/removal/remove-text-using-substrings.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
