To remove the special characters

Hey guys. I would like some help. I’m getting this stream via webhook and I would like to remove the special characters from the phone item. How do I do it inside the n8n?

the workflow

[
{
“headers”: {…}, // 9 keys
“params”: {…}, // 0 keys
“query”: {…}, // 0 keys
“body”: {…}, // 3 keys
“phone”: “(21) 9810-45755”
}
]

I need it to be

“phone”: “21981045755”

thanks

Welcome to the community @acarlostqr

Use a function item node with the following code:

item.phone = item.phone.replace('(', '').replace(')', '').replace('-', '').replace(' ', '')

return item;
Example workflow
2 Likes

@RicardoE105

worked perfectly. Thanks a lot for the help. :slight_smile:

Great that it worked. Have fun.

I’m a beginner and have the same question. However, in my case, the data structure is a little more complex. As can be seen below.
I understand the “replace” part. But how do I select the correct value?

Importat, the below json is the output of the previous node.

"body": {
"lead_id": "TeSter-123-ABCDEFGHIJKLMNOPQRSTUVWXYZ-abcdefghijklmnopqrstuvwxyz-0123456789-AaBbCcDdEeFfGgHhIiJjKkLl",
"user_column_data": [
{
"column_name": "Full Name",
"string_value": "Primeiro nome sobrenome",
"column_id": "FULL_NAME"
},
{
"column_name": "User Phone",
"string_value": "+5547991043088",
"column_id": "PHONE_NUMBER"
},
{
"column_name": "User Email",
"string_value": "[email protected]",
"column_id": "EMAIL"
}
],
...