# Change the order of artists in the Artist field

**URL:** <https://community.mp3tag.de/t/change-the-order-of-artists-in-the-artist-field/59471>\
**Category:** Support\
**Created:** [December 22, 2022, 7:16am UTC](https://community.mp3tag.de/t/change-the-order-of-artists-in-the-artist-field/59471 "2022-12-22T07:16:43Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![tdog](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/t/d07c76/32.png) [@tdog](https://community.mp3tag.de/u/tdog)\
**Post date:** [December 22, 2022, 7:16am UTC](https://community.mp3tag.de/t/change-the-order-of-artists-in-the-artist-field/59471/1 "2022-12-22T07:16:43Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![LyricsLover](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/l/c6cbf5/32.png) [@LyricsLover](https://community.mp3tag.de/u/LyricsLover)\
**Post date:** [December 22, 2022, 7:50am UTC](https://community.mp3tag.de/t/change-the-order-of-artists-in-the-artist-field/59471/2 "2022-12-22T07:50:04Z")

</div>

> [@tdog](#):
>
> `$regexp(%artist%,(.*) & (.*), $3 & $2)`  
> However, I am sure that my logic is wrong.

Specialized 3rd party tools like [regex101](https://regex101.com/r/PTENyj/3) show and explain such (non working) regular expressions - the "searching" part to be exact:

![image](https://community.mp3tag.de/uploads/default/original/2X/d/da210f5187bbd934cc33854d56112857093e28d7.png)

 ![image](https://community.mp3tag.de/uploads/default/original/2X/2/2b3aff6fd988a6cdf1b3b4526c81ebb831b10456.png)

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:

 ![image](https://community.mp3tag.de/uploads/default/original/2X/f/f164f5e803c2e020174c9cadac635d6df3e8ea87.png)

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

---

<div class="post-metadata">

**Author:** ![tdog](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/t/d07c76/32.png) [@tdog](https://community.mp3tag.de/u/tdog)\
**Post date:** [December 22, 2022, 2:44pm UTC](https://community.mp3tag.de/t/change-the-order-of-artists-in-the-artist-field/59471/4 "2022-12-22T14:44:40Z")

</div>

> [@LyricsLover](#):
>
> `$regexp(%artist%,(.+?) & (.+?) & (.*),$1 & $3 & $2)`

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

---

<div class="post-metadata">

**Author:** ![LyricsLover](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/l/c6cbf5/32.png) [@LyricsLover](https://community.mp3tag.de/u/LyricsLover)\
**Post date:** [December 22, 2022, 3:22pm UTC](https://community.mp3tag.de/t/change-the-order-of-artists-in-the-artist-field/59471/5 "2022-12-22T15:22:23Z")

</div>

> [@tdog](#):
>
> Will try to figure the rest of it out

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.

---

<div class="post-metadata">

**Author:** ![tdog](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/t/d07c76/32.png) [@tdog](https://community.mp3tag.de/u/tdog)\
**Post date:** [December 23, 2022, 7:31am UTC](https://community.mp3tag.de/t/change-the-order-of-artists-in-the-artist-field/59471/6 "2022-12-23T07:31:54Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![system](https://community.mp3tag.de/uploads/default/original/2X/c/ce7035d426cb755a7916793326d23b465222a407.png) [@system](https://community.mp3tag.de/u/system)\
**Post date:** [January 22, 2023, 7:32am UTC](https://community.mp3tag.de/t/change-the-order-of-artists-in-the-artist-field/59471/7 "2023-01-22T07:32:49Z")

</div>

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