Index Of
Overview
Use the index of transform to get the location of a specific substring within an incoming value. This transform is often useful in conjunction with the substring transform for getting parts of strings that can be dynamic in length or composition. If the substring you are searching for does not occur within the data, the transform returns -1.
- If the substring you are searching for occurs multiple times within the incoming data, the transform returns the location of the first occurrence. If you want the last occurrence of a substring, use the Last Index Of transform. If you want an occurrence that is neither first nor last, use the Substring transform.
Transform structure
The indexOf transform requires only the substring which you want to search for, along with the type and name attributes:
{
"attributes": {
"substring": "admin_"
},
"type": "indexOf",
"name": "Index Of Transform"
}
Top-level properties (required)
-
type
string(required)
Must be set toindexOf. -
name
string(required)
The name of the transform as it will appear in the UI's dropdown menus. -
requiresPeriodicRefresh
boolean(optional)
Whether the transform logic should be reevaluated every evening as part of the identity refresh process. Default isfalse.
Attributes
The indexOf transform uses the following structure:
{
"type": "indexOf",
"name": "Transform Name",
"attributes": {
"substring": "searchString"
}
}
attributes (required)
The attributes object contains the search configuration.
Required
- substring
string(required)
The string whose beginning location within the incoming data you want to find. Returns-1if not found.
Optional
- input
object(optional)
Explicitly defines the input data passed into the transform. If not provided, the transform uses input from the source and attribute combination configured in the UI.
Examples
The "admin_" substring occurs at the very beginning of the input string, so this transform returns 0.
Input: "admin_jsmith"
Output: "0"
Transform request body:
{
"attributes": {
"substring": "admin_"
},
"type": "indexOf",
"name": "Index Of Transform"
}
Though the letter "b" occurs multiple times throughout the input string, the first time it occurs is within the index location 1, so the transform returns that value.
Input: "abcabcabc"
Output: "1"
Transform request body:
{
"attributes": {
"substring": "b"
},
"type": "indexOf",
"name": "Index Of Transform"
}