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?
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?
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
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.
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'