Split text into array and bundle

I have this output in text form. I want to split them by comma and the output will be in bundle. For example:
Bundle 1:
Name: (name1)
Email: (email1)
Bundle 2:
Name: (name2)
Email: (email2)

image

I used split function and then Iterator for each array, however for the 2nd iterator, it resulted into 2 task because the output on the 1st iterator is already 2

image

Welcome to the Make community!

It looks like you didn’t provide the original text, and how you are splitting them.

1. Screenshots of module fields and filters

Please share screenshots of relevant module fields and filters in question? It would really help other community members to see what you’re looking at.

You can upload images here using the Upload icon in the text editor:
Screenshot_2023-10-07_111039

2. Scenario blueprint

Please export the scenario blueprint file to allow others to view the mappings and settings. At the bottom of the scenario editor, you can click on the three dots to find the Export Blueprint menu item.

Screenshot_2023-08-24_230826
(Note: Exporting your scenario will not include private information or keys to your connections)

Uploading it here will look like this:

blueprint.json (12.3 KB)

3. And most importantly, Output bundles

Please provide the output bundles of the modules by running the scenario, then click the white speech bubble on the top-right of each module and select “Download output bundles”.
Screenshot_2023-10-06_141025

A.

Save the bundle contents in your text editor as a bundle.txt file, and upload it here into this discussion thread.

Uploading it here will look like this:

bundle.txt (12.3 KB)

B.

If you are unable to upload files on this forum, alternatively you can paste the formatted output bundle in this manner:

  • Either add three backticks ``` before and after the code, like this:

    ```
    input/output bundle content goes here
    ```

  • Or use the format code button in the editor:
    Screenshot_2023-10-02_191027

Providing the output bundles will allow others to replicate what is going on in the scenario even if they do not use the external service.

Following these steps will allow others to assist you here. Thanks!

3 Likes

Hi all,
A newbie here.
Can someone please help with the formula to split a text?
Example: Split text into array and bundle - #2 by samliew
Return the text between
https://community.make.com
and /28843/2

Hi @karla ,

Could you precise a little bit more your context?

split function is simple, let’s say that you’ve got a string named text_1 (for example: text_1="Paul-Marie-John-Arthur"), if you apply the split function using the separator -, you will get the array ["Paul", "Marie", "John", "Arthur"].

3 Likes

sorry, looks like the link didn’t copy properly. But what if I need to extract the text? For example:
I need to extract the text between com and /28843

com/t/split-text-into-array-and-bundle/28843/4

It looks a little bit difficult, because it seems that you don’t know the position of what you are looking for in the initial string, that’s it?

Is it only for URL splitting?

3 Likes

the position is always the same:
<a href="CUSTOMLINK" target="_blank">Receive File

I need to extract the custom link. Any tips will be much appreciated

There is something interesting here.

I just hope that regular expressions will not give you a headache…

1 Like

@karla Welcome to the Make community!

That looks like a new question, could you please create a separate topic for this?

While it’s tempting to hop onto an existing thread, a more effective approach would be to start a new topic just for your question. It helps community experts find and respond to your query quicker, and keeps our space organised for everyone. If you start a new conversation you are also more likely to get help from other users. You can refer others back to a related topic by including that link in your question. Thank you for understanding and keeping our community neat and tidy.

The “New Topic” link can be found in the top-right of the header:

Screenshot_2023-12-19_091207

1 Like

Hey @jake1694,
Considering you always expect the same number of items in both “Email” and “Name” fields, and you have validation so the user can’t enter a comma (as we use it as our separator), you can look into this approach:

  • Use a JSON aggregator to enforce the desired data structure
  • We can leverage the “get” function that when provided with an array and an index, will return the relevant array item
  • The repeater “i” can help us as index, and we can use length() to determine the needed number of repeats

It looks like so:

  1. Add a repeater and set number of repeats = {{length(split(2.Email; ", "))}}
  2. Add an “Aggregate to JSON” module, set its source to the repeater, and with the following data structure: {"Email":"","Name":""}

    Set the module as follows:

    Email: {{get(split(2.Email; ", "); 3.i)}}
    Name: {{get(split(2.Name; ", "); 3.i)}}
  3. Parse the aggregated json text:

Output:

Hope this helps!

4 Likes

Hi all,
What would be the best way to return only the country value? The input follows the same format:

Berlin - Germany
Miami - United States
Toronto - Canada
Los Angeles - United States

etc.

Thank you!