How to split text

Hi there!
I have this information:
image
I want to split the text, somthing like
Name: Test
Email: [email protected]
etc
Its possible? I search some information, but I don´t know how to do, any information can help.
Thanks!

Hi @Cesar_Contreras, welcome to the community!

Extracting information from a longer string including static portions of text is typically done using regular expressions.

n8n allows you to execute JavaScript code which in turn gives you access to a number of methods supporting regular expressions. Here’s a quick example of how you could extract values from your example snippet:

To edit the regular expression I’ve used regex101: regex101: build, test, and debug regex. It’s probably not a great expression (I’ve seen much nicer ones here on the forum), but it’ll get the job done :slight_smile:

This is the result:

4 Likes

Wow! thank you! works perfect, I try to do and works. And I can extract must of the text, but when try with the domain, show me error :upside_down_face: also I import the data from gmail. the message afeter domain hace a date something like "Domain: test.com: Date: 2022-05-12 but for some strange reason don´t show the day. Any Idea? so sorry for al incovenience I cause. I really appreciate the answer. Help me a lot.

1 Like

Hey @Cesar_Contreras,

it looks like the node is only told to return the 2 items so if you wanted Domain and Date you would need to update the regex pattern and return the updates results.

1 Like