Get the item in a list of texts that matches a value

So I have a list of texts (courses with rates) Eg. [Mathematics~240, Accounting~200, Geography~210]

I want to get the rate for a particular course using a filter, so if I filter for Mathematics then I want to get 240, if I filter for Geography I want to get 210.

I have searched the forum but can’t find a solution to this. I need help setting up the filter

Well it would be a lot simpler if these were actual objects instead of just texts… (either database or option sets…)

But, you can still do it with texts…

Just take the list and add a filter: this text contains mathematics :first item

Then use :split by ~ :last item to get the number

2 Likes

Hi Adam thanks for this

I already tried this but it just shows a blank. Does “contains” not look for exact matches?

So if text list of course rates is [Mathematics~240, Accounting~200, Geography~210] and I do a list filter for say the text “Accounting”, I feel bubble can’t get the “Accounting~200” because it is not an exact match to “Accounting”.

Maybe a regex extract could be done?

No, contains doesn’t look for exact matches… (that would be is)… contains does exactly what it says… i.e… it checks if a given text contains the text. (e.g. chat contains hat = true)

i.e. if you have a list of texts: [Mathematics~240, Accounting~200, Geography~210]

And you filter them with this text contains Accounting the result will be Accounting~200

No need for regex here… basic Bubble operations are all you need.

(my explanation from the previous reply is working perfectly for me… so you must be doing something wrong if it’s not working).

Hi Adam

It worked!! Thanks so much.

1 Like

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