Help

Upcoming database upgrades. to improve our reliability at 03:30 UTC on Feb. 25 / 7:30pm PT on Feb. 24. Some users may briefly experience slow load times or error messages. Learn more here

Extract a text string from a URL

Topic Labels: Formulas
Solved
Jump to Solution
343 1
cancel
Showing results for 
Search instead for 
Did you mean: 

Hello! Thanks in advance for any help. I am trying to make a formula that will extract a text string from a URL. In this case, the URL is a playlist on Spotify, and the text string is the playlist ID number.

The ID comes after the playlist/ and before the ?, so in this case it would be 5napFAiwbcMwne6jUfmspg

I know this should be fairly easy with REGEX or something, but I’m not up to speed on that stuff yet, so any help would be appreciated!

Thanks!

1 Solution

Accepted Solutions

Hey @Dennis_Petrou!

So, this formula will work when it comes to the format of the URL you provided.

REGEX_EXTRACT(
    RIGHT(
        {Name},
        42
    ),
    '\\w*'
)

image


If the Spotify URLs you’re working with are always in that format, then this formula will work fine.
Now, if you’re dealing with different formats, then you’re going to run into problems, as the formula I provided has a hard-coded value that removes the entire https://open.spotify.com/playlist/ from the string.

From there, the formula just extracts every alpha-numeric character sequentially, which means it will always stop at the ? in the remaining string.


Truth be told, I’m not the fondest of this formula since it doesn’t work for different URL formats, but I’m merely human.
Let me know if you have more complex requirements, and we can definitely go from there.

See Solution in Thread

1 Reply 1

Hey @Dennis_Petrou!

So, this formula will work when it comes to the format of the URL you provided.

REGEX_EXTRACT(
    RIGHT(
        {Name},
        42
    ),
    '\\w*'
)

image


If the Spotify URLs you’re working with are always in that format, then this formula will work fine.
Now, if you’re dealing with different formats, then you’re going to run into problems, as the formula I provided has a hard-coded value that removes the entire https://open.spotify.com/playlist/ from the string.

From there, the formula just extracts every alpha-numeric character sequentially, which means it will always stop at the ? in the remaining string.


Truth be told, I’m not the fondest of this formula since it doesn’t work for different URL formats, but I’m merely human.
Let me know if you have more complex requirements, and we can definitely go from there.