Replace in String transform Icon Replace in String

Description

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 for special characters

Supported Engines

Hop Engine

Supported

Spark

Supported

Flink

Supported

Dataflow

Supported

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 egular 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 vlaue 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.