Split String Operator
Overview
Sometimes, you might want to divide your string values. The Split String operator lets you separate values in one string into their own array values. You start by using the operator's Info window to designate a separator, which is a place for the operator to split your string. A separator is anything from a dash to a comma to a unique string of your choosing. Once you configure your Data Workfow, the operator splits your string wherever it finds that separator. Then, the Split String operator stores your new data as their own array elements.
Let's say your health insurance company wants to track the login timestamps of your end-users. You want to keep logins organized and accessible. The Split String operator can split the timestamp into an array of smaller strings. First, it searches for the separator. Then, it splits your string into separate string values in an array.
You’ll find the Split String operator under the Value/String group at the left of the Data Workflow canvas.
Similar Data Workflow Operators
The Split String operator is similar to the Split Field operator. Here are the operators compared:
-
Split String operator: Divides strings into smaller strings at each separator value.
-
Split Field operator: Divides larger data sets into smaller field values at each separator value.
What You'll Learn
In this
About the Info Window
Here's what the Split String operator looks like, along with its Info window:
And here's a breakdown of each setting in the Info window:
Setting |
Description |
---|---|
Category |
Grayed out and non-adjustable setting indicating the operation type. |
Label |
Sets the label for your operator. The label you enter here shows beneath your operator on your Data Workflow canvas. This field is optional, but set a label if you use more than one of the same operator type. A label helps you identify your operators without opening any Info windows. |
Separator |
The point where you want the operator to split your data. These are often some form of punctuation mark but can also be numbers, a string, or a phrase. Common separators include: ;, -, :, _, and ,. |
Adding a Split String Operator
To see the Split String in action, let's revisit the timestamp example from earlier. Start with a Hidden component. This component stores the UTC (Coordinated Universal Time) login timestamp of your insurance customer. Then, a Data Workflow with a Split String operator splits the timestamp into separate strings.
Here's how the completed use case looks in the Module Builder:
Here's how the completed use case looks in Express View along with a look at the DevTools Console:
What You Need
To set up this use case, you need:
-
1 Hidden component
-
1 Button component
-
1 Data Workflow component
To set up your Data Workflow, you need:
-
1 Input operator
-
1 Split String operator
-
2 Console operators
NOTE These instructions assume you have a new module open, saved, and with a title.
Configure the Hidden Component
First, you need a Hidden component to store your UTC timestamp.
1. | Drag and drop a Hidden component onto your canvas. |
2. | Enter lastLoginStamp in the Property ID and Canvas Label Text fields. |
3. | Click Save. |
Configure the Data Workflow Component
Now, add your Data Workflow component, bringing your data in using an Input operator. Then, use a Split String operator to separate values in your lastLoginStamp string at each dash [-].
1. | Drag and drop a Data Workflow component onto your canvas. Place your Data Workflow below your Hidden component. |
2. | Enter dwfSplitStamp in the Canvas Label Text and Property Name fields. |
Configure the Input Operator
This operator brings in your source data.
1. | Drag and drop an Input operator onto your Data Workflow canvas. |
2. | Configure the Input operator's Info window as follows: |
Setting |
Value |
---|---|
Category |
Input |
Component |
lastLoginStamp |
Required |
Yes |
Source |
Default |
Configure the First Console Operator
This operator shows your data before being split.
1. | Drag and drop a Console operator onto your Data Workflow canvas. |
2. | Configure the Console operator's Info window as follows: |
Setting |
Value |
---|---|
Category |
Console |
Label |
Original |
3. | Connect the output port (right) of the Input operator to the input port (left) of the Console operator. |
Configure the Split String Operator
This operator splits each string at the -.
1. | Drag and drop a Split String operator onto your Data Workflow canvas. |
2. | Configure the Split String operator's Info window as follows: |
Setting |
Value |
---|---|
Category |
Split String Value |
Label |
- |
Separator |
- |
3. | Connect the output port (right) of the Input operator to the input port (left) of the Split String operator. |
Configure the Second Console Operator
This operator shows your data after being split.
1. | Drag and drop a second Console operator onto your Data Workflow canvas. |
2. | Configure the Console operator's Info window as follows: |
Setting |
Value |
---|---|
Category |
Console |
Label |
Dash |
3. | Connect the output port (right) of the Split String operator to the input port (left) of the Dash Console operator. |
4. | Click Save. |
Configure the Button Component
Next, add a Button to trigger your Data Workflow.
1. | Drag and drop a Button component onto your canvas. Place your Button between your Hidden component and Data Workflow. |
2. | Enter btnSplitStamp in the Property ID field. |
3. | Enter Split Timestamp in the Label Text field. |
4. | Select Event as the Action Type. |
5. | Enter dwfSplitStamp in the Trigger on Click field. |
6. | Click Save. |
7. | Save your module. |
Now, preview your module in Express View. Start by opening the DevTools Console. Then, click the Split Timestamp button. In the Console, you see updates from your two Console operators. The Original Console shows you the original string you stored in your Hidden component. When you expand the Dash Console array, you can see how the original string split into an array of four string values. Because you entered the dash as the separator, your original string separated at each dash symbol.
Changing a Split String Operator's Settings
You can revisit and make changes to this operator.
1. | Click the Data Workflow component. |
A 5-button toolbar displays above the component on hover-over.
2. | Click the (Settings) button to open the Data Workflow canvas. |
3. | Click the operator to open its Info Window. |
4. | Make changes to the operator's settings as needed. |
5. | Click Save. |
6. | Save your module. |
Copying a Split String Operator
You can make a copy of your operator using familiar keyboard settings. You can copy and paste an exact copy of your operator, matching all settings.
1. | Hover over the Data Workflow component. |
A 5-button toolbar displays above the component on hover-over.
2. | Click the (Settings) button to open the Data Workflow canvas. |
3. | Click the operator you want to duplicate. |
4. | On your keyboard, press Command + C (Mac OS) or Ctrl + C (Windows/Linux) to copy the operator. |
TIP You can copy more than one operator at a time. Hold Command or Ctrl on your keyboard and click all the operators you want to copy. Follow the rest of the steps as usual.
5. | On your keyboard, press Command + V (Mac OS) or Ctrl + V (Windows/Linux) to paste the copied operator(s) to the Data Workflow canvas. |
6. | Click Save. |
7. | Save your module. |
TIP Did you know you can copy an operator and paste it into a different Data Workflow? You'll use the same steps outlined above.
Removing a Split String Operator
Lastly, you can delete this operator from your Data Workflow canvas. You can also use these same steps to delete a connection between two operators.
1. | Hover over the Data Workflow component. |
A 5-button toolbar displays above the component on hover-over.
2. | Click the (Settings) button to open the Data Workflow canvas. |
3. | Click the operator you want to delete. |
4. | On your keyboard, press Delete. |
NOTE Once you delete this operator, make sure to connect your remaining operators. If your Data Workflow path doesn't end with an Output or Console operator, your Data Workflow won't work. So, once you delete an operator, make sure to update any remaining paths to end at an Output or Console operator.
5. | Click Save. |
6. | Save your module. |
Lab
You can view this complete use case here: https://training.unqork.io/#/form/60c923f79dac8302d2f16bfe/edit.