Limited Time Offer: Watch All Our Bubble Tutorial Videos for Only $99 per Year!

Using truncate & split by to extract data from text

In this Bubble tutorial we demonstrate how text can be extracted and manipluated using truncate and split by in the Bubble app builder editor.

In this quick video, I will show you how to use the 'Truncated to' and the 'Split by' functions in Bubble to extract and manipulate a longer string of text.

So I have an input field here with a long string of text and here are just some of the ways that I can extract different bits of data from it. So I have a text field down here and I'm going to say Input A's value.

Truncated to...

And then let's say I just want the first 12 characters so I can use the truncate to 12 and then if I hit preview, it will show me the first twelve characters.

Truncated from end to...

Okay, now what if I wanted to do that from the end? Well, Bubble also has a truncated from end, which if I refresh now, we just get the last 12 characters.

If I go back to truncated from the start, truncated to and refresh, we'll see that this isn't so perfect because it's quite brutal to count by characters.

Split by

So what I wanted to extract the first three words. Well that's when I can use split by. Split by creates a list type in bubble. So if I say split by space and then I say items until 3 and then 'Join with'... Let me just show you what this would look like to start with, this will list out the first three words, but by default Bubble puts a comma between each one. In order to get rid of that comma, I can use the 'Join with' space.

So there we go. I now have the first three words, and if I wanted the first four words, I can get the first four words.

Those are just a couple of really handy tricks for reformatting the data that your users, the text data that your users may be putting into your app in order to get them in the format that you want.

Example: Extracting first name and last name

One example when this isn't going to be perfect would be first names and last names. I say it's not perfect because some people may have like a shorter, so they may have a shorter word in the middle, like Mac for example, followed by their surname.

But let me show you how this would work really well with first names and last names. So think of a first name, last name, I'll just put Tony Stark.

So how would I extract just the first name? Well, I can go with the 'Split by' a space and then I can just say first item. And then if I wanted the last name, I can go for last item.

There you go. That's just one example of how these little tricks, knowing how to manipulate string data and Bubble can be really helpful.

 

Latest videos

crossmenu