Repeating Groups - Show every n-th item



Dear community, I am relatively new to bubble and creating an App that calls the ChatGPT API to iterate travel ideas. The API response is a string, that separates the fields by “;”. In Bubble, I am splitting the text by that operator and this works perfectly fine. However, in order to format each column separately, I created three text fields (for each column one). My issue is the following:

What I want:

Day, Activity, Cost
Item1, Item2, Item3
Item4, Item5, Item6

What I currently get with modulo:

Day, Activity, Cost
Item 1, “”, “”
“”, Item2, “”
“”, “”, Item3

However, i would like to have everything on the same line. Spent hours experimenting with Find&Replace, nested operations, Regex, but I just don’t know anymore how to proceed.

Thanks!

I can’t quite make sense of what you’re doing… but do you have to use ‘Text’ as the RG content type? Can’t you use the API response data instead?

The API response is unfortunately one gigantic string.

The “Group Response Field’s response” is basically that text from the API.

Wow! That’s a mess!! (if it wasn’t for the extra : where it says the price it would be very simple)…

Will the price field always contain the colon? Or does that depend on the response? And will the words used always be either Cost or Fee? (if yes then the solution is not too hard)

I think i could get rid of the “:”. Either refining the API call or maybe replace : with a space. Let me give you another API response:

Thanks so much for taking the time!

I was only talking about the : inside the price field (not the ones that split the items… you need those)

If you’re able to determine the format of the API response, keep it as you originally had it (Day and Time;Activity;Cost:) but just make sure there aren’t any additional : in the texts (like there were before)… or use a different symbol in the Cost field etc.

Then it’s simple…

Just split the overall text by : for the RG datasource

Then just split each text by ; inside the cell and display items 1, 2, and 3 accordingly.

Thank you.

Might be a silly question, but how does “Then just split each text by ; inside the cell and display items 1, 2, and 3 accordingly.” work?
I have three text fields (one for each column) in the RG to have unique formatting per column (e.g. cost column should be narrow, Activity should be wide). How can I achieve that?

If you’re initial text is something like:

Day and Time;Activity;Cost:08.00am;Start your journey...;Train ticket cost 30CHF:10.00am;Arrive in Berne......;Park admision fee 8CHF:12.00pm;Continue your expl...;Lunch cost 25 CHF:02.00pm;From here, take a ...;Admission Fee 20 CHF

Split that by :

That will give you a list of texts (which you’ll use as the data source of your RG):

Day and Time;Activity;Cost
08.00am;Start your journey...;Train ticket cost 30CHF
10.00am;Arrive in Berne......;Park admision fee 8CHF
12.00pm;Continue your expl...;Lunch cost 25 CHF
02.00pm;From here, take a ...;Admission Fee 20 CHF

Then inside each cell, take the text (e.g. 08.00am;Start your journey...;Train ticket cost 30CHF) and split it by ; to get another list of texts:

08.00am
Start your journey...
Train ticket cost 30CHF

Then just refer to the relevant item from that list (i.e. first item, item# 2, and last item) in your text boxes.

e.g.

In the first text box set the dynamic content to Current cell's Text: split by ; first item

In the second text box set the dynamic content to Current cell's Text: split by ; item# 2

In the third text box set the dynamic content to Current cell's Text: split by ; last item

Thank you!!! This gave me the final hint and in the end, I was overcomplicating by a lot. It was resolved by split first by “backspace” and then by “;”. Here’s the final result

Thank you so much for investing your time to help.

1 Like

This topic was automatically closed after 70 days. New replies are no longer allowed.