fbpx

Bubble’s new expressions: SPLIT BY and ARBITRARY TEXT explained

Follow me:

Bubble quietly launched two new features in July 2021 that are quite useful: split by and arbitrary text. They’re both expressions that solve tiny problems that otherwise would require cumbersome workarounds, and are absolutely worth checking out. You’re not gonna use every day – but you’ll love it when you need it. So let’s check them out.

What is the SPLIT BY expression?

As the name suggests, this operator will take any text and split it into a list (array) of texts by a given character. In other words, you can use this expression to take a string of text such as Adam,Mary,John and convert it into a list. You would normally have to resort to regex to get this done, so this adds another sigh of relief to those who signed to Bubble to… you know… not write code.

How to turn a text into a list of texts

In the example below, I’ve stored the text Adam,Mary,John as the data source on a group with data type text. In a repeating group, I’ve set the type of content also to text, and in the data source, I reference the text stored in the group. I then add the :split by operator to turn that string into a list of texts. In step 3, I tell Bubble that the comma is the character that separates them.

Turning a text into a list of texts in Bubble
Quickly converting the text Adam,Mary,John to a list of texts by using the SPLIT BY expression

Converting a text into a list of numbers

So, can I use this same expression to return a list of numbers instead? Why yes! Yes you can! But it takes an additional step. If you hover the split by operator at the end of the expression, you’ll see that it always returns a list of texts:

Converting a text into a list of numbers in Bubble.io
Hovering any step in an expression will tell you what kind of data is returned – in this case a list of texts.

Luckily, the :convert to number operator works for both single entries and lists. By adding one more step to the expression, we can turn any list of comma-separated (or any other character) numbers into a list:

Using the :converted to number operator to turn a list of texts into numbers.
By adding the :converted to number operator, we can make Bubble return a list of numbers instead of text.

What is the arbitrary text expression?

Working with text in Bubble can sometimes be a frustrating experience, as some editor input fields will accept concatenated values just fine (meaning to combine several text values, both dynamic and static, to make up a final value), while others stubbornly refuse to accept anything more than a single value (strangely, the Set state command only supports the latter for example). The :append expression partly solves this, but still leaves the whole process feeling clunky and inflexible.

The :arbitrary text expression is basically a multi-line input field that you can use to replace the limited input fields around the Bubble editor. This is great for several reasons. First of all, it makes more complex expressions a lot easier to read, since you can view them in a multi-line input. Secondly, you can return the final result of the expression as a single value that you can then add one more additional steps to that value:

Adding an additional step to an arbitrary text expression in Bubble.
Arbitrary text allows you to return the result of one ore more concatenated expressions as a single value.

While Bubble’s focus on raising a $100m has taken up a lot of their attention lately, and they’ve been (in their own words) comically understaffed for the last couple of years, I find that these small updates that do pop up quite frequently do actually add up to some serious value over time. I’ll be using both of these frequently, and I don’t think I’m alone.

If you want to learn more about Bubble, check out our basic and advanced tutorials, as well as the book The Ultimate Guide to Bubble Performance. You can also read our in-depth review of Bubble here.

Support the site and keep it free ❤️

I love tech startups and the Bubble community, and have made it my mission to try and create content that’s valuable, easy to follow and entertaining.

Creating content next to full-time consulting work is time-consuming; if you’d like to support it and keep the site free for everyone, please consider buying me a coffee or becoming a supporting member.

Buy Me A Coffee

Follow me:
Bubble.io books

Learn Bubble the right way

Our professional Bubble books teach you how to plan, structure and build your applications right from the start.

5-star review stars

More Posts

Leave A Reply

Your email address will not be published. Required fields are marked *

*

Email icon

Useful articles and tips

Join the mailing list to get guides, opinions and articles on Bubble, no-code, automation and the tech industry.

We don't share your email address with anyone, and you can unsubscribe at any time.

You have successfully subscribed