Column Name Replacer

Renames all columns based on a search & replace pattern. The search pattern is a regular expression, literal, or wildcard expression.

In the simplest case, you can search and replace string literals. E.g. if the input columns are called "Foo 1", "Foo 2", "Foo 3", etc and the search string is "Foo", the replacement is "Bar", the output would be "Bar 1", "Bar 2", "Bar 3".

More complicated cases contain capturing groups, i.e. expressions in parentheses that, if matched in a column name, are saved. The groups can be referenced in the replacement string using $g, whereby g is a number 0-9. These placeholders will be replaced by the original occurrence in the input column name. For instance, to rename the columns that are produced by the Data Generator node (they follow a scheme Universe_<number1>_<number2>) to <number2> (Uni <number1>), you would use as search string: "Universe_(\d+)_(\d+)" and as replacement: "$2 (Uni $1)".

The special sequence $i represents the current column index (unless escaped by '\' (backslash)). E.g. in order to precede each column name with the column index, use as search string "(^.+$)", capturing the entire column name in a group, and as replacement "$i: $1".

Further documentation regarding regular expressions can be found in the Java API documentation, in particular the classes Pattern and Matcher.

Options

Pattern type
Select the type of pattern which you want to use.
  • Literal matches the pattern as is.
  • Wildcard matches * to zero or more arbitrary characters and matches ? to any single character.
  • Regular expression matches using the full functionality of Java regular expressions, including back references in the replacement text. See the Java API for details.
Use backslash as escape character
If checked, the backslash character can be used to escape special characters. For instance, \? will match the literal character ? instead of an arbitrary character. In order to match a backslash you need to escape the backslash, too (\).
Case sensitive
Specifies whether matching will distinguish between upper and lower case letters.
Pattern
A literal string, wildcard pattern or regular expression, depending on the pattern type selected above.
Replacement text
The replacement text for the pattern. If you are using a regular expression, you may also use backreferences (e.g. $1 to refer to the first capture group. Named capture groups can also be used with (?<group>) and ${group} to refer to them).
Replacement strategy
Select what to replace in case a string matches a pattern.
  • Whole string replaces the entire string with the replacement string, requiring an exact match of the whole string.
  • All occurrences replaces all occurrences of the pattern with the replacement string. Note that when e.g. matching on the RegEx-pattern .*, an empty string at the end of the input is also matched and replaced. To avoid that, use e.g. the pattern ^.* to indicate that the match has to start at the beginning of the string.

Input Ports

Icon
The table with columns to rename.

Output Ports

Icon
The table with renamed columns.

Views

This node has no views

Workflows

Links

Developers

You want to see the source code for this node? Click the following button and we’ll use our super-powers to find it for you.