Identity now: Transform for last last word from last name

Hello,
I am trying to get the last last word from the last name field

My transform looks like this:

{
    "attributes": {
      "begin": {
        "attributes": {
            "input": {
                "attributes": {
                    "name": "lastName"
                },
                "type": "identityAttribute"
            },
          "substring": " "
        },
        "type": "lastIndexOf"
      },
      "beginOffset": 1
    },
    "type": "substring"
  }

The issue with mine is i want the last word of a last name after spaces and special characters. I don’t think substring input takes regex expressions. is there a way around that?

Example:
Last name: Velery-Smith
Output: Smith

Hello @salam1,

You should be able to use the split transform here. In the example you gave split on the - character and the second index will be your last name.

Try out this transform:

{
    "attributes": {
        "delimiter": "-",
        "index": 1,
        "input": {
            "attributes": {
                "name": "lastName"
            },
            "type": "identityAttribute"
        }
    },
    "type": "split",
    "name": "Split Transform"
}

Thank you for responding! However, it is not considering spaces though. I would like the last word after spaces or special characters.

Example:
Last name: John Denver-Smith
Output:Smith

Last name: John-Denver Smith
Output: Smith

Hello @salam1,

I added a replaceAll to replace - and & characters with spaces. You can add more to the table object to replace other special characters if need be.

Also, I needed to provide the same last name input to the outer substring and it worked.

{
    "attributes": {
        "begin": {
            "attributes": {
                "input": {
                    "type": "replaceAll",
                    "attributes": {
                        "input": {
                            "attributes": {
                                "name": "lastName"
                            },
                            "type": "identityAttribute"
                        },
                        "table": {
                            "-": " ",
                            "&": " "
                        }
                    }
                },
                "substring": " "
            },
            "type": "lastIndexOf"
        },
        "beginOffset": 1,
        "input": {
            "attributes": {
                "name": "lastName"
            },
            "type": "identityAttribute"
        }
    },
    "type": "substring",
    "name": "Last Word of Name"
}
1 Like

Awesome! Thank you so much! Your’e amazing! @tyler_mairose
I actually wrote this today as well, Would this work too?

{
    "attributes": {
        "delimiter": "-",
        "index": 1,
        "input": {
            "attributes": {
              "begin": {
                "attributes": {
                    "input": {
                        "attributes": {
                            "name": "lastName"
                        },
                        "type": "identityAttribute"
                    },
                  "substring": " "
                },
                "type": "lastIndexOf"
              },
              "beginOffset": 1
            },
            "type": "substring",
            "name": "Last Name Split"
          }
    },
    "type": "split",
    "name": "lastnamesplitspecialcharacters"
}

I used the split function and allowed the result of substring as input. i am not sure if i should have a name for input “last name split”

Sorry, finally wanted to ask, if we can add regex expression to the table as well? Regex example - [^a-zA-Z]

Yes, you can add regex to the table as well! Take a look here at our documentation for replaceAll