Change the order of artists in the Artist field

I am trying to fix some incorrect tags where there are 3 artists who are listed in incorrect order.
Example:
Dreamy & Claire Willis & Daniel Kandi
Should be Dreamy & Daniel Kandi & Claire Willis
Then I have an action that would replace the second ampersand with "Feat".
I have this expression:
$regexp(%artist%,(.*) & (.*), $3 & $2) but it does not work.
The way i understand this expression is it should swap artist 3 and artist 2.
However, I am sure that my logic is wrong.

Specialized 3rd party tools like regex101 show and explain such (non working) regular expressions - the "searching" part to be exact:

image

You have only 2 capturing groups $1 and $2 in your regular expression, therefore you can't replace the content of the not existing $3.

For your specific situation, something like this should work:
$regexp(%artist%,(.+?) & (.+?) & (.*),$1 & $3 & $2)

Explanation:

Please test it carefully. And to be clear, this works for ARTIST names with two & characters separating three artist names in it.

This seems to work. I may need to also have slight variations. Will try to figure the rest of it out. Appreciate your help.

1 Like

Thank you for your feedback.
You need to search for a unique separator between the artist names (like the &). With this separator you should be able to adjust the regular expression.

That's exactly what I did. Your initial code was what I needed, and now I was able to modify it based on my needs. So far no issues!

1 Like

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