The substring transform function extracts part of a string value based on a given start point (i.e. where to begin counting) and a given length (i.e. how many characters to return).
A start value can be a positive or negative number, where:
Positive numbers count from the start (left to right)
Negative numbers count from the end (right to left)
Counting starts at 0.
To better understand how this works, consider the example payload below:
{"greeting":"good morning"}
The positive and negative indices for this string value are shown below:
G o o d _ m o r n i n gIndex +01234567891011 (from start) Index --12-11-10-09-08-07-06-05-04-03-02-01 (fromend)
Now we can easily work through some sample settings:
Start
Length
Output
0
4
good
1
3
ood
5
7
morning
-7
7
morning
-12
4
good
-15
4
good
Notice that the last sample setting has a length counting back further than the actual length of our sample string value. In this case, counting goes back as far as possible.
Adding a substring transform
Step 1
In your process flow, access settings for your map shape:
Step 2
Select the add transform icon for the required mapping rule - for example:
Step 3
Click the add transformbutton:
Step 4
Click in the namefield to access a list of all available transform functions, then select substringfrom the stringcategory:
Step 5
In the start field, enter the position at which counting should begin - for example:
Remember:
Counting starts at zero
A positive number counts from left to right
A negative number counts from right to left
Step 6
In the length field, enter the number of characters to return - for example:
Step 7
Click the add fieldbutton:
Step 8
Click in source fieldsand select the source field to be used for this transform:
Step 9
Accept your changes (twice) and then save the transform. You'll notice that the transform icon is updated to indicate that a transform function is present for the mapping row - for example: