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.
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:
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:
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:
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.