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.

Supported Engines

Hop Engine

Supported

Spark

Supported

Flink

Supported

Dataflow

Supported

Options

Option Description

Transform name

Name of the transform.

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 or it will create a new field.

use RegEx

Use regular expressions (Y/N).

Search

Search for a certain pattern. Can use a wildcard (*) for searching in the Search column.

Replace with

Replace with certain characters.

Set empty string?

Turn string into an empty string.

Replace with field

Replace the pattern with a field value.

Whole word

Whole word (Y/N).

Case sensitive

Is the search case sensitive (Y/N).

Is Unicode

Is the search unicode (Y/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.

Metadata Injection Support

All fields of this transform support metadata injection. You can use this transform with ETL Metadata Injection to pass metadata to your pipeline at runtime.