REGEX: remove first 3 characters

Hi all,

I’m trying to remove the first 3 characters of a string (any characters, even spaces). It seems that @supernaturally had a solution in that thread (now closed), but it’s giving me the first 3 characters, not removing them. This seems to be one of the things we can’t do with Bubble’s built-in options (truncate, truncate from end to, etc.).

Anyone has a REGEX expression that works?

Thanks a lot.


Haven’t actually tried this, but could you:

  1. Do a count of the string to get the total number of characters
  2. Subtract the amount you want (i.e 3)
  3. Do a truncate from end with the result of step 2
1 Like

Yep, I was just doing this. It works :wink:

Kinda of a workaround, but well, that’s what Bubble is all about ^^


1 Like

I had to use Math.js local to achieve this, because after “truncated from end to” I couldn’t do a calculation.

1 Like

@Lucien if you still want to use regex to remove the first 3 characters you can do the following.
I think it will be faster than calling an api to do any calculations.

Note that i’m using the :find and replace instead of the :extract with regex.
Basically we’re using regex to find the first 3 characters and replace it with empty string - that is why the Replace by box is empty


Oh, that makes sense. So it was the correct pattern, I just wan’t using it in the right way!

Thanks a lot!

Yes because you were using :extract with regex.
So with that pattern it is extracting the first 3 characters for you.
But what you wanted was to use the pattern to find the first 3 characters and replace them with empty (which essentially removes them).


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