Regex Question: Comma being added at the end of extracted string

Hi

I have a text string:

https://www.google.com/maps/place/?q=place_id:ChIJlX4jakcY0i0R7uBwcrKi8XA

I am using the following regex in a text element to extract just the Google Place ID from this string:

(?<=.{46}).*

It works perfectly but Bubble is adding a comma at the end so instead of getting the result:

ChIJlX4jakcY0i0R7uBwcrKi8XA

I am getting:

ChIJlX4jakcY0i0R7uBwcrKi8XA**,** (a comma is placed at the end)

Can anyone possible point me in the direction of how to avoid or get rid of that comma at the end?

Any input really appreciated…

Hi there, @anon71899553… you might have tried this already, but can you do a find and replace on the result of the regex to find a comma and replace it with nothing?

Best…
Mike

Hi there @mikeloc
Thanks for taking the time to help me out!
I had not thought of that…great idea.
Humm,.,how to do this?
I currently have the following
image
…but I am just not sure how to then do the find and replace (I think its a neat idea but)
Cheers Simon

You should be able to get the More… option at the end of the expression (you might have to click around a bit… try clicking directly on extract with Regex). After you click More…, select the :find & replace operator, enter a comma as the text to find, and don’t put anything in the replace by field.

Hey @mikeloc Too easy - thanks so much. Really appreciated mate…
(I learn so much for all your answers on the forum btw… :rocket:)

1 Like

I have the exact same issue, with a comma being added at the end of extracted string of text. The issue is, the text will often have commas within the text, so a search and replace will not work. Any other workarounds that I could try?

@JCM, try using the :truncated to operator to truncate the string to the string’s number of characters minus 1.

I worked! Thanks so much!! Been struggling with that for a loooong time lol

1 Like