Fixing multiple 'feat.' in the artist field

Hi all,
I've made a bit of a mess of my library and I'm trying to fix it but have long since hit the limit of my ability with regex.

My artist fields all look something like this:
Westside Gunn feat. Busta Rhymes feat. Raekwon feat. Ghostface Killah feat. Stove God Cooks

What I'm trying to get to is something like:
Westside Gunn feat. Busta Rhymes, Raekwon, Ghostface Killah & Stove God Cooks....or
Westside Gunn feat. Busta Rhymes, Raekwon, Ghostface Killah, Stove God Cooks would be fine too.

Does anyone have any suggestions as to how I can deal with these extra 'feat.' values?

Thanks all

I don't see how a regular expression could guess that in this case the " feat. " should be replaced
with " & "
For the other cases, you want to replace all the " feat. " with a comma and a space, but not the first occurrence of " feat. ", right?

I thought getting the last one as '&' was a step too far but yes, all but the first 'feat.' as a comma and space would be fantastic if possible

Try an action of the type "Format value" for ARTIST
Format string: $replace($regexp($replace($regexp(%artist%,(.*?) feat\. (.*),$1==$2), feat.,','),'(.*), (.*)',$1 & $2),==, feat. )

From
Westside Gunn feat. Busta Rhymes feat. Raekwon feat. Ghostface Killah feat. Stove God Cooks
to:
"Westside Gunn feat. Busta Rhymes, Raekwon, Ghostface Killah & Stove God Cooks

1 Like

Would you mind to tell us in a short explanation how this works? :wink:

That is exactly it. Thank you so much I really appreciate the help.
That has handled all of the tracks in Westside Gunn's album '10' with varying numbers of featured artists.
Thanks again.

Format string: $replace($regexp($replace($regexp(%artist%,(.*?) feat\. (.*),$1==$2), feat.,','),'(.*), (.*)',$1 & $2),==, feat. )
You have to read that inside out.
So: take the initial string from artist and replace the first "feat." with == so that it is something else than all the other "feat"s. You get the first with the greadiness-reducer "?" in the first group description.
Now replace all the other "feat." in that string with == by commas.
Then use a regular expression to replace the last comma with an ampersand.
and finally replace the == with "feat." again.

2 Likes

Just to add a note on to this for anyone else who might need to use this solution on their own files - just be aware of any artists with a comma in the name.

There might be a more elegant way to do this but I've run a step before hand to change the artist name (so 'Tyler, the Creator' is changed to 'Tyler the Creator')... then run the fix ...then run a final step to change 'Tyler the Creator' back to 'Tyler, the Creator'

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.