Help

Re: Extract a text string from a URL

Solved
Jump to Solution
1617 0
cancel
Showing results for 
Search instead for 
Did you mean: 
Dennis_Petrou
7 - App Architect
7 - App Architect

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
Ben_Young1
11 - Venus
11 - Venus

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
Ben_Young1
11 - Venus
11 - Venus

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.