Split Data from Webhook

How can i split name, email, and phone from text , so that i can process my next node

































“text”:“Name : xxxx Phone : 000000 Email : yyyyy”,











Hi @chandan988 :wave:

I recorded a quick video on how you can do this. I kept the video generic to make it reusable, but I used your exact example.

The only difference with your example is that your text key might be nested in another data structure. But if you drag and drop it’s key into the expression like in my video, that will all get auto-mapped for you.




“data”:“Name : edrftgyhujikol Phone : dsfdddd Email : ddddkd”



I tried But my output is coming like this
{{ $json[“data”].split(" ")[4] }}

After putting split my output is

[Array: [“Name : edrftgyhujikol\r\nPhone : 34567890567\r\nEmail : dddddd”]] in this format

This is because the data in your screenshot is different from the example you shared. Some of the spaces are being translated to linebreak characters (\n ).

If that is happening consistently (i.e. the linebreak chars are always in same place), you could use a combination of split(" ") and "split(\n") to extract the specific infos you need.

If however that varies from input to input, that is sometimes it’s separated by a " " and sometimes by a “/n” … then it becomes a bit more complicated and the first step would be for you to understand if it varies in a predictable way. For example, maybe there are just 2x subcases of variation. If so, my initial thought would be to add an IF node that checks for the specific case (perhaps with regex check) and then routes that item to a set node with an expression to extract that specific format (be it \n or a space)


Another quick thought: if it is only \n that are sometimes replacing spaces (and it’s happening intermittently). Then you could “clean” the text string before you perform the .split(" ").

To do so, we basically need to replace every instance of \n with " " (a space). We do have a .replace() function in n8n and a .replaceAll(), we need the latter :point_down:

.replaceAll("\n", " ") ← that should be the snippet you need to clean the data first.

In full: {{ $json.text.replaceAll("\n", " ").split(" ")[5] }}

That only works if you have 1x “rouge” separator. Though you could chain multiple “replaceAll” functions after each other if you do have a set list of separators you need to clean + swap for a space.


Thanks a lot @maxT for Quick Reply and support

1 Like

My pleasure, glad to hear it helped and thanks for letting the community know that it was a working solution - will help others find this answer in future :slight_smile:

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.