Jun 30, 2022 09:14 AM
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!
Solved! Go to Solution.
Jun 30, 2022 02:02 PM
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*'
)
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.
Jun 30, 2022 02:02 PM
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*'
)
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.