Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Table of Contents
maxLevel2
typeflat

...

How does it work in the search window?

Select Create column in the search window toolbar, then select the Substitute operation. You need to specify at least three arguments:

Argument

Data type

More information

String to scan mandatory

string

You can select a column in the table or enter a value manually.

Regular expression mandatory

regexp

You can select a column in the table or enter a value manually. If you introduce it yourself, you can use the regexp syntax to establish grouping patterns.

Template mandatory

template

You can select a column in the table or enter a value manually. If you introduce it yourself, you can use the capturing group syntax to make reference to specific groups established by the regular expression.

Fail value optional

string

You can select a column in the table or enter a value manually.

The data type of the values in the new column is string.

Note

Note that Devo automatically changes the strings manually entered in the Regular expression and Template arguments to the required regexp and template data types. If you want to use a column on these arguments, it must be a regexp/template type column. You can use the Regular expression, regexp (re) and Template (template) operations to transform a string column to the required data type.

Example

In the demo.ecommerce.data table, we want to replace the first colon value (:) in every string of our timestamp column by a hyphen (-). We will create a new column using the Substitute operation to do it.

...

Click Create column and you will see the following result:

...

We can also create a column in the demo.ecommerce.data table that substitutes the first dot in IP addresses by a space. To do it, we will create a new column using the Substitute operation and we will call it Substitute. Before that, we need to transform the clientIpAddress column into string type using the to string (str) operation and we will call it IPstring.

Once we have the IPstring column, the arguments needed to create the new Substitute column are:

...

Note

Note that when you enter a string value as a regular expression and template using LINQ, you have to transform them to regexp and template format using the Regular expression, regexp (re) and Template (template) operations, as you can see in the examples. This is not needed if you perform this operation directly from the search window interface, as said above.

Example

You can copy the following LINQ script and try the previous examples on the demo.ecommerce.data table.

Code Block
breakoutModewide
languagesql
from demo.ecommerce.data
  select subs(timestamp, re(":"), template("-")) as substitute_timestamp

...