# Replace in String

## <img src="/files/d3kp2YqgM3PrUM766WAd" alt="" data-size="line"> Replace in String

### Description <a href="#description" id="description"></a>

The Replace In String transform performs simple search and replace operations on String fields.

It also supports regular expressions and group references. group references are picked up in the replace by string as $n where n is the number of the group.

You can also use [hexadecimal replacements](/data-shaper-1.21/knowing-the-data-shaper-designer/variables.md#hexadecimal-values) for special characters.

| Hop Engine | <sup>✓</sup> |
| ---------- | ------------ |
| Spark      | <sup>✓</sup> |
| Flink      | <sup>✓</sup> |
| Dataflow   | <sup>✓</sup> |

### Options

| Option             | Description                                                                                                                                                             |
| ------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Transform name     | Name of the transform. This must be unique within a plugin.                                                                                                             |
| In stream field    | The field in which a replacement has to take place.                                                                                                                     |
| Out stream field   | The result field. If you leave the Out stream field empty, it will replace the value in the In stream field. Otherwise, the replacement value is output in a new field. |
| use RegEx          | Specify whether a regular expression is used for specifying the value to replace. This value must be Y or N.                                                            |
| Search             | Search for a certain pattern. You can use a wildcard (\*) for matching multiple characters. If you are using a regular expression, specify the pattern in this field.   |
| Replace with       | Specify the value to replace the search pattern with. If you are using regular expressions, specify the replacement part of the string here.                            |
| Set empty string?  | Specify whether the field value is replaced with a blank string. This value must be Y or N.                                                                             |
| Replace with field | Replace the search pattern with the value from the field you specify.                                                                                                   |
| Whole word         | Specify whether the whole word must match the search pattern to be replaced. This value must be Y or N.                                                                 |
| Case sensitive     | Specify whether the search is case sensitive. This value must be Y or N.                                                                                                |
| Is Unicode         | Specify whether the search uses unicode encoding. This value must be Y or N.                                                                                            |

### Example

You could parse out sections of a string as follows

* regex = ^(\[0-9]{4})(\[0-9]{7})$
* replace with = $2

This will replace any 11 digit numbers with the last 7 digits.


---

# 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.primeur.com/data-shaper-1.21/knowing-the-data-shaper-designer/pipelines/transforms/replacestring.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.
