# Find and replace

## Description

This operation allows you to search for specific patterns within your input data and replace them with new text.

***

## Data types

These are the input/output expected data types for this operation:

### Input data

![](https://965373739-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkxZeV4nlXcIAjMGZxzLI%2Fuploads%2FZmr35bwgundYfOW63E3q%2Fimage.png?alt=media\&token=2ba8baff-b40b-4dd4-ae2c-2a2ad5696788) - Text or data where you want to perform find-and-replace operations.

### Output data <a href="#output-data" id="output-data"></a>

![](https://965373739-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkxZeV4nlXcIAjMGZxzLI%2Fuploads%2FZmr35bwgundYfOW63E3q%2Fimage.png?alt=media\&token=2ba8baff-b40b-4dd4-ae2c-2a2ad5696788) - Output strings after the find-and-replace operations.

***

## Parameters

These are the parameters you need to configure to use this operation (mandatory parameters are marked with a <mark style="color:red;">**\***</mark>):

<details>

<summary>Substring to find<mark style="color:red;"><strong>*</strong></mark></summary>

Enter the text or pattern you want to find in the input.

</details>

<details>

<summary>Replacement<mark style="color:red;"><strong>*</strong></mark></summary>

Enter the text with which you want to replace each match. You can use RegEx patterns here.

</details>

<details>

<summary>Global Match<mark style="color:red;"><strong>*</strong></mark></summary>

Set `true` if you want to replace all matches found. If this is set to `false`, only the first match will be replaced. The default value is `true`.

</details>

<details>

<summary>Case Insensitive<mark style="color:red;"><strong>*</strong></mark></summary>

Set `true` if you want to ignore case when matching. The default value is `false`.

</details>

<details>

<summary>Multiline<mark style="color:red;"><strong>*</strong></mark></summary>

Set `true` to enable multiline mode. This feature controls how to treat line breaks in the input. Specifically, it affects the behavior of the `^` and `$` anchors in the RegEx patterns you use in the **Substring to find** parameter.

* When **Multiline** is enabled:
  * `^` matches the **start of a line**, not just the start of the whole input.
  * `$` matches the **end of a line**, not just the end of the whole input.
  * This means the regex treats the input as **multiple lines**, and you can match patterns at the beginning/end of each line.
* When **Multiline** is disabled:
  * `^` and `$` only match the **start and end of the entire input**, respectively.
  * This is useful for matching patterns that span across the whole input or aren't line-sensitive.

The default value is `false`.

### **Example**

Example with **Multidata** **activated**:

**Input data:**

```
Info: All systems operational  
Error: Disk space low  
Warning: CPU usage high  
Error: Memory leak detected
```

* **Substring to find** - `^Error:.*`
* **Replacement** - `ALERT`
* **Multiline** - `true`

**Output data:**

```
Info: All systems operational  
ALERT  
Warning: CPU usage high  
ALERT
```

***

Example with **Multidata** **deactivated**:

**Input data:**

```
Info: All systems operational  
Error: Disk space low  
Warning: CPU usage high  
Error: Memory leak detected
```

* **Substring to find** - `^Error:.*`
* **Replacement** - `ALERT`
* **Multiline** - `false`

**Output data:**

```
Info: All systems operational  
Error: Disk space low  
Warning: CPU usage high  
Error: Memory leak detected
```

Because `^` only applies to the **start of the whole input** with multiline off, the pattern never matches.

</details>

<details>

<summary>Dot Matches All<mark style="color:red;"><strong>*</strong></mark></summary>

Set `true` to match new line characters. Specifically, this affects how the `.` (dot) behaves in the RegEx patterns you use in the **Substring to find** parameter.

When **Dot Matches All** is enabled, the dot (`.`) **also matches newline characters**, allowing patterns to match across **multiple lines**.

The default value is `false`.

### **Example**

Example with **Dot Matches All** **activated**:

**Input data:**

```
<start>
line 1
line 2
<end>
```

* **Substring to find** - `<start>.*<end>`
* **Replacement** - `[BLOCK]`
* **Dot Matches All** - `true`

**Output data:**

```
[BLOCK] 
```

`.*` **includes newlines**, so everything from `<start>` to `<end>` is matched and replaced.

***

Example with **Dot Matches All** **deactivated**:

**Input data:**

```
<start>
line 1
line 2
<end>
```

* **Substring to find** - `<start>.*<end>`
* **Replacement** - `[BLOCK]`
* **Dot Matches All** - `false`

**Output data:**

```
<start>
line 1
line 2
<end>
```

`.*` does **not** match across newlines, so no match occurs.

</details>

***

## Examples

Suppose you want to **replace all the occurrences** of the word "error" with "issue". To do it:

1. In your Pipeline, open the required [Action](https://docs.onum.com/the-workspace/pipelines/actions) configuration and select the input **Field**.
2. In the **Operation** field, choose **Find and replace**.
3. Set **Substring to find** to `error`.
4. Set **Replacement** to `issue`.
5. Set **Global Match** to `true`.
6. Set **Case Insensitive** to `true`.
7. Set **Multiline** to `false`.
8. Set **Dot Matches All** to `false`.
9. Give your **Output field** a name and click **Save**. The count will be displayed in the output field.

{% hint style="info" %}
You can try out operations with specific values using the **Input** field above the operation. You can enter the value in the example above and check the result in the **Output** field.
{% endhint %}

In this example, given the following string:

<pre><code><strong>"The server encountered an error while processing your request"
</strong></code></pre>

you'll get this output:

```
"The server encountered an issue while processing your request"
```


---

# Agent Instructions: 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.onum.com/the-workspace/pipelines/actions/transformation/field-transformation/field-transformation-operations/utils/find-and-replace.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.
