> For the complete documentation index, see [llms.txt](https://docs.onum.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.onum.com/pipelines/actions/transformation/field-transformation/field-transformation-operations/utils/find-and-replace.md).

# 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

`String` - Text or data where you want to perform find-and-replace operations.

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

`String` - 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](/pipelines/actions.md) 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"
```
