Last name transform to exclude apostrophe

Hi,
I have built a transform that excludes special characters from last name. This was done so we can create email using the last last word of last name.

Example input
Last name: Test Romen-Apple
lastwordtransform output: Apple

However, my transform is not handling apostrophe’s correctly.

Example input:
Last name: Test D’test
lastwordtransform output: test

I would like to remove apostrope as well and would like the below expected output

Expected output:
Last name: Test D’test
lastwordtransform output: Dtest

I tried to use replace all table but it is not working. Can you please tell me what I am missing? Thank you!

Current transform below:

{
    "name": "Last Word Transform",
    "type": "substring",
    "attributes": {
        "begin": {
            "attributes": {
                "input": {
                    "type": "replaceAll",
                    "attributes": {
                        "input": {
                            "attributes": {
                                "name": "lastNameAccountCreate"
                            },
                            "type": "identityAttribute"
                        },
                        "table": {
                            "[^a-zA-Z]": " ",
                            "[']":""
                            
                        }
                    }
                },
                "substring": " "
            },
            "type": "lastIndexOf"
        },
        "beginOffset": 1,
        "input": {
            "attributes": {
                "name": "lastNameAccountCreate"
            },
            "type": "identityAttribute"
        }
    }
}

Have you tried removing the square brackets and just specifying the apostrophe like this "'":""

Hi Colin,
I did it like you said but now its returning the output as below:
Last name: Test D’test
lastwordtransform output: test

Would like the output to be dtest.

Maybe its the order of operation in the replace all table? I would like it to remove the apostrophe and then replace any special characters with " " and the offsetbegin at position 1.

Yea, that’s quite possible. It looks like the regex for your first replace will match on the apostrophe and replace it with a space. Try moving that regex pattern after your apostrophe replacement to see if it works.

I did this but that didn’t work either.

 "table": {
                            "'":"",
                            "[^a-zA-Z]": " "
                            
                        }

It’s possible that the apostrophe you are seeing is not in ASCII, but UTF-8. This might explain why your table isn’t matching the apostrophe. Just to highlight the difference:

  • This is an ASCII single quote: '
  • This is the apostrophe you provided:

Try copy/pasting that exact character into your replacement table rather than typing the single quote.

I copy/pasted exactly but still no luck.

"table": {
                                "'": "",
                                "[^a-zA-Z]": " "
                            }

I still think there is some copy paste issues going on. Try using the unicode equivalent of the right quotation mark.

"table": {
                                "\u2019": "",
                                "[^a-zA-Z]": " "
                            }

Hi Colin,
I test the unicode equivalent as well. It didn’t work. Is this something you can test in your environment?

Thank you.