How to add parentheses to an update statement (trim first 4 chars)

Hi gang. When storing a new thing, I’m trying to do my users a favor and strip out the leading 4 characters ("The ") when its title begins with the word “The” I have a title and a sort-title. I’m attempting to store this truncated title in the sort-title field.

In my Update a Thing step (conditional on things that start with "The ") I’m trying to do the following:
sort-title = this thing’s sort-title:truncated from end to
(this thing’s sort-title :number of characters - 4)

So if the title was “The One” using the above equation…
sort-title = The One: truncated from end to
(3)
because total number of chars =7 and 7-4=3
so the value stores is “one”

The problem is, I can’t seem to put parens or brackets around my X-Y piece. I’ve tried clicking in every spot, zoomed in, and still no joy. Any suggestions or different approaches? Thanks!

Maybe try enabling the experimental parentheses feature?

Best…
Mike

1 Like

thanks for the heads up! I just enabled but I haven’t figured out how to use it yet. It’s putting parens around the entire thing, but I only want to put it around the X-Y piece. Will dig into it though, thanks again!

1 Like

Guessing there’s a RegEx solution here too. Trim the first 4 characters isn’t a tall order so hopefully I can get this figured out…

Have you tried :find & replace —> ‘The ’ for nothing.

For order of operations and parentheses I use :arbitrary text a lot (you can convert to number back in the main expression if it’s numerical)… obviously native parenthesis will be great once they’re fully fledged though.

1 Like

thanks for the suggestions, @exception-rambler . Unfortunately, I haven’t been able to make either one work yet. But I’m gonna keep at it. :slight_smile:

thanks again @exception-rambler - I finally got it. I ended up using find & replace as you suggested.

I was just about to respond with a couple of examples that appear to do what you described, @ThatFizzGuy, so what the heck, I will put them out there. Ignore the fact that I used the User data type for the example… oh, I assume you added some sort of only when condition, too?

1 Like

@mikeloc thanks! I would VERY much love to see a video/screencast showing how exactly you got those parens input in your first example. That’s what I was TRYING to input before my original post. :slight_smile: No rush, and no worries if you don’t feel like it. I got it working with the find/replace similar to your second example.


thanks again!

1 Like

Well, in this case, I think that would be a pretty uninteresting video. I just built out the expression, and Bubble put the parentheses in the right places. The only interesting part was where to put the - 4 part of the expression, and it went here.

parens

As soon as I added the - 4, Bubble automatically removed the open parenthesis at the beginning of the expression and added the open parenthesis after :truncated from end to. Seriously, the experimental parentheses feature is downright awesome, if you ask me.

1 Like

Interesting! Thanks @mikeloc

I played with that experimental parens feature earlier today, and when I noticed it putting the open parens at the very start of my expression, I bailed since I couldn’t figure out how to move it to the spot I wanted the open. I guess I should have kept typing and waited for some magic to happen! :slight_smile: Will give it another look…

thanks again, sir!

1 Like