Regex Expression & Bubble Find+Replace Help

I have a regex expression that identifies all of the spaces plus extra lines successfully but when I try and run it as a Bubble Find and Replace (replaced with nothing) nothing happens for some reason.

What am I doing wrong?

image

Hi there, @JustinC… I’m not sure why the regex isn’t working, but if you string two :find & replace operators together with the first one finding a space (literally type a space in the Text to find field) and replacing it with nothing and the second one finding a line break (literally press Enter in the Text to find field) and replacing it with nothing, you should get the desired result, assuming I have understood your post correctly.

Hope this helps.

Best…
Mike

If you want to find and replace any whitespace (spaces, tabs, line breaks) with regex what you need is simply \s

For some reason it doesn’t want to work and I don’t understand why.

When I test the RegEx at regex101.com, it identifies the matches fine.

Is this regex usable in bubble?

/^[ \t]+|[ \t]+$/gm

I see in the reference, there is some jargon as follows:

Tip: Bubble uses JavaScript Regex, which handles certain expressions differently than other flavors (such as PHP). Similarly, we do not yet expose capture groups so your expressions might need a little more massaging. For example, consider the following scenario:

You’d like to extract all of the characters in the following urlhttps://domain.com/abc/text-that-i-want after the pattern ‘abc/’. A commonly used expression might be abc\/(.*) . Used in Bubble, this would extract ‘abc/text-that-i-want’. Thus, we need to adjust the expression to (?<=wf\/)(.*) to exclude the ‘abc/’ using a positive lookbehind. This would leave us with just ‘text-that-i-want’.

We recommend using a Regex builder to test your expressions before using them in Bubble.

that regex is usable in bubble but is probably doing something different from what you think. Keep in mind that bubble is doing the search with a global flag only.
Again, if your goal is to replace all kind of whitespace \s is all you need.
If it doesn’t work post example strings and the corresponding result that you want.

Hi @dorilama I did try using the \s regex expression but it removes all the text and leaves commas. Can you confirm I can do this by using the :extract with regex command line?

\s will match any king of whitespace. If you use it in find and replace you replace them, if you use it with the extract operator you get a list of whitespace text (whitesapce is extracted and everything else is discarded) and if you diplay it in a text in bubble you see just whitespace characters with comas in between.
So your problem here is that you are using the wrong operator.

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