splitfield

Split values in one column into new columns using a regular expression.

This guide explains how to configure the splitfield instruction. To learn about another instruction, go back to the Available custom script instructions overview.

Introduction

Use the splitfield instruction to split the values in one column into new columns. Use a regular expression to determine how the values are to be split.

Creating a custom script enrichment using the splitfield instruction

To create and configure a custom script using the splitfield instruction, follow these steps:

  1. Create a custom script enrichment.

  2. In the Instructions step, select the splitfield instruction.

  3. To configure the custom script instruction, fill in the required fields below, as well as any optional fields you require:

Field (required)

Enter the name of the column that contains the values to split.

Pattern (required)

Enter a regular expression used to split the values into new columns.

New fields (required)

Enter the names of the new columns to populate with the split values.

Include original

Select this field to keep the column from which the values are split.

Maxsplit

Enter a number for the maximum number of times a value can be split. Any values that can be split are left combined in the last column of the data extract (see the example below). Enter 0 to not provide a limit.

Flags

Enter a flag for the regular expression. A regular expression flag is used for global and case-insensitive searching.

Subtable

Enter the name for a subtable that you want to use within this custom script.

A subtable is a temporary table that only exists for this custom script. You can apply additional instructions within the same custom script to the subtable. However, the subtable cannot be used in any other custom scripts.

If a subtable does not exist for the current custom script, the enrichment is applied to the data extract, and the enriched data is output into the subtable. If the subtable already exists for the custom script, the subtable is used as the input for the enrichment and optionally as the output.

Example

Enrichment configuration

Field

Campaign

Pattern

_

Newfields

  • Quarter

  • Campaign name

  • Campaign ID

Include Original

Select this field

Maxsplit

3

Data table before enrichment

Campaign

Ad Group

Clicks

Q1_NewYear_887

media

7

Q1_WinterClearout_445

ecommerce

3

Q2_Spring_1272_BA

festivals

18

Q1_Valentines_992_887

ecommerce

4

Q4_Christmas_2525

media|social

5

Q1_PayDay_881

media

11

Data table after enrichment

Campaign

Ad Group

Clicks

Quarter

Campaign Name

ID

Q1_NewYear_887

media

7

Q1

NewYear

887

Q1_WinterClearout_445

ecommerce

3

Q1

WinterClearout

445

Q2_Spring_1272_BA

festivals

18

Q2

Spring

1272_BA

Q1_Valentines_992_887

ecommerce

4

Q1

Valentine

992_887

Q4_Christmas_2525

media|social

5

Q4

Christmas

2525

Q1_PayDay_881

media

11

Q1

PayDay

881