Replace in String
The Replace in string step performs a simple search and replace. This step supports regular expressions and group references. Group references are shown in the Replace with column as $n, where n is the number of the group.
Step name
Enter the following information in the transformation step field:
Step name: Specify the unique name of the step on the canvas. The default is Replace in string. You can customize the name or leave it as the default.
Fields string table

Use the following table to specify the replacement string and related options.
In stream field
Specify the field to replace from the PDI input stream. Click Get Fields to add all fields from the input stream(s).
Out stream field
Specify the new field name to output to the PDI stream.
Use RegEx
Select Y or N to indicate whether to use a regular expression to search for values.
Search
Specify the string to search for.
Replace with
Specify the string to replace the matched value.
Set empty string?
Select Y or N to indicate whether to replace null values with empty strings.
Replace with field
Specify a field value to use as the replacement value.
Whole word
Select Y or N to indicate whether to replace the entire word of the matched value.
Case sensitive
Select Y or N to indicate whether the search is case sensitive.
Is Unicode
Select Y or N to indicate whether the search value is a sequence of Unicode characters.
You can click Get Fields to add all fields from the PDI input stream.
Example: Use regular expression group references
When using regex (regular expression) group references, matching patterns are represented by a sequence of integer values with a dollar sign prefix. For example, $1 for the first group match, $2 for the second group match, and so forth.
To replace a portion of the incoming value contained in In stream field, use a group value token to represent the portion of the string that the group matched.
For example, suppose the string value of In stream field is Homer Simpson.
To switch the first and last name:
Set Use RegEx to
Y.Set Search to
/([a-zA-Z]*) ([a-zA-Z]*)/.Each pattern inside parentheses represents a group, so
$1=Homerand$2=Simpson.
Regular expression group example Set Replace with to
$2 $1.This places
Simpsonfirst, followed byHomer.
For more information about regular expressions, see https://www.regular-expressions.info/brackets.html.
Metadata injection support
All fields of this step support metadata injection. You can use this step with ETL metadata injection to pass metadata to your transformation at runtime.
See also
Last updated
Was this helpful?

