> For the complete documentation index, see [llms.txt](https://docs.selfuel.digital/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.selfuel.digital/data-integration-with-nexus/nexus-elements/transform/replace.md).

# Replace

> Replace transform plugin

### Description[​](https://seatunnel.apache.org/docs/2.3.7/transform-v2/replace#description) <a href="#description" id="description"></a>

Examines string value in a given field and replaces substring of the string value that matches the given string literal or regexes with the given replacement.

### Options[​](https://seatunnel.apache.org/docs/2.3.7/transform-v2/replace#options) <a href="#options" id="options"></a>

| name           | type    | required | default value |
| -------------- | ------- | -------- | ------------- |
| replace\_field | string  | yes      |               |
| pattern        | string  | yes      | -             |
| replacement    | string  | yes      | -             |
| is\_regex      | boolean | no       | false         |
| replace\_first | boolean | no       | false         |

#### replace\_field \[string][​](https://seatunnel.apache.org/docs/2.3.7/transform-v2/replace#replace_field-string) <a href="#replace_field-string" id="replace_field-string"></a>

The field you want to replace

#### pattern \[string][​](https://seatunnel.apache.org/docs/2.3.7/transform-v2/replace#pattern-string) <a href="#pattern-string" id="pattern-string"></a>

The old string that will be replaced

#### replacement \[string][​](https://seatunnel.apache.org/docs/2.3.7/transform-v2/replace#replacement-string) <a href="#replacement-string" id="replacement-string"></a>

The new string for replace

#### is\_regex \[boolean][​](https://seatunnel.apache.org/docs/2.3.7/transform-v2/replace#is_regex-boolean) <a href="#is_regex-boolean" id="is_regex-boolean"></a>

Use regex for string match

#### replace\_first \[boolean][​](https://seatunnel.apache.org/docs/2.3.7/transform-v2/replace#replace_first-boolean) <a href="#replace_first-boolean" id="replace_first-boolean"></a>

Whether replace the first match string. Only used when `is_regex = true`.

#### common options \[string][​](https://seatunnel.apache.org/docs/2.3.7/transform-v2/replace#common-options-string) <a href="#common-options-string" id="common-options-string"></a>

Transform plugin common parameters, please refer to [Transform Plugin](/data-integration-with-nexus/nexus-elements/transform/transform-common-options.md) for details

### Example[​](https://seatunnel.apache.org/docs/2.3.7/transform-v2/replace#example) <a href="#example" id="example"></a>

The data read from source is a table like this:

| name     | age | card |
| -------- | --- | ---- |
| Joy Ding | 20  | 123  |
| May Ding | 20  | 123  |
| Kin Dom  | 20  | 123  |
| Joy Dom  | 20  | 123  |

We want to replace the char to `_` at the `name` field. Then we can add a `Replace` Transform like this:

```
transform {
  Replace {
    source_table_name = "fake"
    result_table_name = "fake1"
    replace_field = "name"
    pattern = " "
    replacement = "_"
    is_regex = true
  }
}
```

Then the data in result table `fake1` will update to

| name      | age | card |
| --------- | --- | ---- |
| Joy\_Ding | 20  | 123  |
| May\_Ding | 20  | 123  |
| Kin\_Dom  | 20  | 123  |
| Joy\_Dom  | 20  | 123  |

### Job Config Example[​](https://seatunnel.apache.org/docs/2.3.7/transform-v2/replace#job-config-example) <a href="#job-config-example" id="job-config-example"></a>

```
env {
  job.mode = "BATCH"
}

source {
  FakeSource {
    result_table_name = "fake"
    row.num = 100
    schema = {
      fields {
        id = "int"
        name = "string"
      }
    }
  }
}

transform {
  Replace {
    source_table_name = "fake"
    result_table_name = "fake1"
    replace_field = "name"
    pattern = ".+"
    replacement = "b"
    is_regex = true
  }
}

sink {
  Console {
    source_table_name = "fake1"
  }
}
```
