IdentityNow Transforms - Split

IdentityNow Transforms - Split

Overview

The split transform allows you to use a specific character or regex string as a delimiter, and convert a single incoming string value into an array of values. The transform will then return the Nth element of that array. This can come in handy when trying to split combined names into their constituent parts, or when an ordered list of values needs to be simplified into a single attribute.

Other Considerations

  • N/A

 

Transform Structure

In addition to the standard type and name attributes required by all transforms, the split transform also requires the delimiter and index attributes. These parameters, respectively, tell the transform what to use as the pattern to split the string with, and which entry in the resultant array of values you are interested in getting back.

Example

{
  "attributes": {
    "delimiter": ",",
    "index": 5
  },
  "type": "split",
  "name": "Test Split Transform"
}

Attributes

  • Required Attributes

    • type - This must always be set to split
    • name - This is a required attribute for all transforms, and represents the name of the transform as it will appear in the UI's dropdowns
    • delimiter - This can be either a single character or a regex expression, and is used by the transform to identify the break point between two substrings in the incoming data
    • index - An integer value for the desired array element after the incoming data has been split into a list; the array is a 0-based object, so the first array element would be index 0, the second element would be index 1, etc.
  • Optional Attributes

    • requiresPeriodicRefresh - A true or false value that indicates whether the transform logic should be re-evaluated every evening as part of the identity refresh process.
    • throws - A boolean (true/false) value which indicates whether an exception should be thrown and returned as an output when an index is out of bounds with the resultant array (i.e., the provided index value is larger than the size of the array)

      • true - The transform should return "IndexOutOfBoundsException"
      • false - The transform should return null
      • If not provided, the transform will default to false and return a null

 

Examples

Example 1

Input: "abc:123"

Output: "123"

{
  "attributes": {
    "delimiter": ":",
    "index": 1
  },
  "type": "split",
  "name": "Test Split Transform"
}

This example takes the incoming attribute configured in the identity profile attribute UI, splits it based on the colon (":") character, and returns the second array element (array index 1).

Example 2

Input: "The quick brown fox jumped over 10 lazy dogs"

Output: "fox"

{
  "attributes": {
    "input": "The quick brown fox jumped over 10 lazy dogs",
    "delimiter": " ",
    "index": 3,
    "throws": true
  },
  "type": "split",
  "name": "Test Split Transform"
}

This example takes the explicit string provided, splits it based on the space (" ") character, and returns the fourth word (array index 3).

 

References

  • N/A
Comments

If you need to split on a dot (.) use this for a delimiter instead of the dot.

"delimiter": "\\.",

@vkoldenh thanks for mentioning this, I was definitely stuck. I ran into the same issue, but when trying to split as an opening parenthesis: (

I tried your solution and it worked:

"delimiter": "\\("

 An additional FYI - I had to apply @vkoldenh 's solution to the Replace Transform as well, in the "regex" attribute:

"regex": "\\)",
"replacement": ""

 

Thank you for your help with this. 

I've been trying to split a value based on anything after the last space.

So in the instance of Giovanni Haldeen Brockhorst (let's assume that's a user's name) I'd love to chop it up into 3 pieces, call back the first item on the array and the last. In this case though it's easy enough to just delimit on spaces with an index of 2.

But the previous solution doesn't necessarily work when we hire on someone with 4 or 5 names.

Let's use Akon, yep, the R&B singer, as an example; his name on IMDB is "Aliaune Damala Bouga Time Bongo Puru Nacka Lu Lu Lu Badara Akon Thiam". In a perfect world I get this shortened down to Aliaune.Thiam you know?

Looking forward to what yall think! I don't know if this question would be better suited in the Trim, Split, Index, or any other specific transform comments instead.

 

 

@Ryan_DeLeon for your use case you'll probably need a nested transform with

Split - to get the first word using space as a delimiter.

LastIndexOf - to find the position of the last space.

Substring - using the result from LastIndexOf as the begin attribute to get the last word

Concatenation - to bring everything together into first.last

@Ryan_DeLeon And because it was spinning around in my head - here you go, my very first nested transform
 

 

{
  "id": "First and Last",
  "attributes": {
    "values": [
      {
        "attributes": {
          "delimiter": " ",
          "index": 0
        },
        "type": "split"
      },
      ".",
      {
        "attributes": {
          "begin": {
            "attributes": {
              "substring": " "
            },
            "type": "lastIndexOf"
          },
          "beginOffset": 1
        },
        "type": "substring"
      }
    ]
  },
  "type": "concat"
}

 

Tested with your example "Aliaune Damala Bouga Time Bongo Puru Nacka Lu Lu Lu Badara Akon Thiam"
FirstLast is the above transform applied to the Display Name

2022-04-08_22-28-30.png

 

Hi,

I am trying to use double quote(") as a delimiter in a transform to split a string.

I tried using "\"", "\\"" but the escape character is not working.

Can someone please help me on this?

Version history
Revision #:
3 of 3
Last update:
‎Dec 09, 2021 05:18 PM
Updated by:
 
Contributors