Regex results in unwanted characters

In the above screenshot, I am using Regex:

(?<=.{46}).*

To extract

ChIJPxObTns40i0Rbw_tKYPZuwY

from the URL

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

But the result I am getting returns a comma and space at the end:

ChIJPxObTns40i0Rbw_tKYPZuwY, (comma and space after the comma)

Is there anything I can do to either:

(a) Extract the desired string in a better way; or

(b) Prevent the comma and space being added at the end?

Many thanks for your time!

Hi there, @anon71899553… assuming the structure of the URL is always the same, you can use Bubble’s :split by operator with the separator being a colon, and then add the :last item operator to the expression and you should get the desired result.

Hope this helps.

Best…
Mike

Hi Mike
Ah! Perfect…thank you so much.
Another tip I have learned from you…really appreciated @mikeloc

2 Likes

Aside: It would be nice if there were an API to the expression builder for adding stuff like this. (Because the “real” way to do this would be to turn the string into a URLSearchParamsobject and then just get the value of the place_id parameter. :man_shrugging: Basically, this already exists in the “get data from page URL” expression.)

1 Like

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