Split first name and second name of a form field

Hey guys,

I am migrating from integromat to n8n and need to split the first name and second name of a form received via webhook and capitalize the words.

Any ideas how I can do this on n8n?

Thanks in advance

Note: In integromat the solution I use is shown below:

Screen Shot 2021-06-14 at 3.23.20

Hey @bbarbi!

Welcome to the community :sparkling_heart:

Can you share the output that you receive? If you’re familiar with JavaScript, you can use the Function node and write custom code to do this :slight_smile:

1 Like

Thank you very much Harshil :raised_hands:

I was already considering that function node would be the best solution for this problem. Unfortunately my javascript knowledge is very basic. I will study about it. :+1:

1 Like

No worries :slight_smile:

If you face any issues, or need any help, feel free to post it here :slight_smile:

1 Like

I don’t know if it’s correct, but it worked. :raised_hands: :raised_hands: :raised_hands:

Learning code little by little. :heart:

N8N is awesome!

Screen Shot 2021-06-14 at 6.58.02

2 Likes

Yaay! This is amazing. I am so happy that you’re learning to code as well :wink:

FYI. If it is a smaller code snippet and you are referencing it once you can use it in the Expression editor as well. Below is an example that will help you understand it better

The first Set node (Set name) is creating mock data. The second Set node (Split name), uses the .split() method and references the first and last name.

I hope this helps :slight_smile:

1 Like

Yes, it helps a lot. :heart:

Thank you for your help @harshil1712 :facepunch:

1 Like

Hello @bbarbi another approach is to using directly in the expression like this in cases when you have more than two words in the value of name.

firstname = {{$json[“Name”].split(" “)[0]}}
lastname = {{$json[“Name”].split(” ").slice(1).join(’ ')}}

5 Likes

Thank you @rodrigoscdc :facepunch: :+1: