Replace (In Database)
Synopsis
This operator replaces parts of the values of nominal attributes.
Description
This operator replaces parts of the string values of all nominal attributes it is applied on. The attribute filter type gives the possibility to restrict them. For each value of each attribute it is checked if the regular expression of replace what matches the string. Each matching part of the string will be replaced by the value of the replace_what parameter. The replacement might be empty and can contain capturing groups.
Please keep in mind that certain databases may not support regular expressions, in that case a design-time warning will appear if special characters are used. Also note that regular expressions may differ between different database engines. Please consult the documentation of your database regarding more complicated examples.
Note that the output data type for the columns with replaced values may depend on your database (e.g. LONGTEXT in case of MySQL that becomes Text in RapidMiner). In other cases, the replace expression may cause that the value becomes too large for the default return data type, in which case the result may be erroneous (e.g. max 4000 characters in Oracle).
Examples
- replacing "color" by "" yields: " red", " green", " blue"
- replacing "color" by "colour" yields: "colour red", "colour green", "colour blue"
- replacing "color\s" by "" yields: "red", "green", "blue"
- replacing "\s+" by "_" yields: "color_red", "color_green", "color_blue"
Input
example set input
Output
example set output
Parameters
Attribute filter type
The condition specifies which attributes are selected or affected by this operator.
Attribute
The attribute which should be chosen.
Attributes
The attribute which should be chosen.
Regular expression
A regular expression for the names of the attributes which should be kept.
Use except expression
If enabled, an exception to the specified regular expression might be specified. Attributes of matching this will be filtered out, although matching the first expression.
Except regular expression
A regular expression for the names of the attributes which should be filtered out although matching the above regular expression.
Value type
The value type of the attributes.
Use value type exception
If enabled, an exception to the specified value type might be specified. Attributes of this type will be filtered out, although matching the first specified type.
Except value type
Except this value type.
Block type
The block type of the attributes.
Use block type exception
If enabled, an exception to the specified block type might be specified.
Except block type
Except this block type.
Numeric condition
Parameter string for the condition, e.g. >= 5
Invert selection
Indicates if only attributes should be accepted which would normally filtered.
Replace what
A regular expression specifying what should be replaced.
Replace by
The replacement for the region matched by the regular expression. Possibly including capturing groups.