# Regex issues when rearranging multivalue tag

**URL:** https://community.mp3tag.de/t/regex-issues-when-rearranging-multivalue-tag/71734
**Category:** Mac
**Created:** [August 16, 2026, 12:08pm UTC](https://community.mp3tag.de/t/regex-issues-when-rearranging-multivalue-tag/71734 "2026-08-16T12:08:38Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![kauwelhoner](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/k/9de0a6/32.png) [@kauwelhoner](https://community.mp3tag.de/u/kauwelhoner)
#### Post date: [August 16, 2026, 12:08pm UTC](https://community.mp3tag.de/t/regex-issues-when-rearranging-multivalue-tag/71734/1 "2026-08-16T12:08:38Z")

</div>

I‘m using MP3Tag on a MacBook and try to generate artistsort from artist. Both fields are used with multiple values.

So artist:

Oscar Peterson\\Dizzy Gillespie\\Clark Terry\\Eddie "Lockjaw" Davis\\Niels-Henning Ørsted Pedersen\\Bobby Durham

should result in artistsort:

Peterson, Oscar\\Gillespie, Dizzy\\Terry, Clark\\"Lockjaw" Davis, Eddie\\Ørsted Pedersen, Niels-Henning\\Durham, Bobby

If I export the artist tag, I can rearrange it with

sed -E 's/(^|\\)([^\\]+) ([^\\]+)(\\|$)/\1\3, \2\4/g' output.txt \> input.txt

properly.

But the action import from file in MP3Tag will only import the first value (Peterson, Oscar).

On the other hand I failed to set up an action in MP3Tag first copying artist to albumartist (this works) and afterwards reformatting the tag Artistsort with the regex command I‘m using in sed because of the missing Parameter -E.

Did you find another way to generate a multiple sort-tag from the original tag? Any ideas are welcome.

---

<div class="post-metadata">

### Author: ![ohrenkino](https://community.mp3tag.de/user_avatar/community.mp3tag.de/ohrenkino/32/4843_2.png) [@ohrenkino](https://community.mp3tag.de/u/ohrenkino)
#### Post date: [August 16, 2026, 12:18pm UTC](https://community.mp3tag.de/t/regex-issues-when-rearranging-multivalue-tag/71734/2 "2026-08-16T12:18:22Z")

</div>

> [@kauwelhoner](#):
>
> But the action import from file in MP3Tag will only import the first value (Peterson, Oscar).

You would have to show us the data and the applied function.  
AFAIK the action imports the whole text filed into just 1 field in all the selected files.  
If you want to get a single record from the text file into a specifc audio file and distribute the data into several fields, you would have to use Convert\> Text file - Tag.

---

<div class="post-metadata">

### Author: ![Florian](https://community.mp3tag.de/user_avatar/community.mp3tag.de/florian/32/5759_2.png) [@Florian](https://community.mp3tag.de/u/Florian)
#### Post date: [August 16, 2026, 12:47pm UTC](https://community.mp3tag.de/t/regex-issues-when-rearranging-multivalue-tag/71734/3 "2026-08-16T12:47:45Z")

</div>

> [@kauwelhoner](#):
>
> Did you find another way to generate a multiple sort-tag from the original tag?

You can use an action **Format tag field** for `ARTISTSORT` using

`$regexp($metasep(artist,\\),'(^|\\)([^\\]+) ([^\\]+)(\\|$)','$1$3, $2$4')`

---

<div class="post-metadata">

### Author: ![kauwelhoner](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/k/9de0a6/32.png) [@kauwelhoner](https://community.mp3tag.de/u/kauwelhoner)
#### Post date: [August 16, 2026, 5:15pm UTC](https://community.mp3tag.de/t/regex-issues-when-rearranging-multivalue-tag/71734/4 "2026-08-16T17:15:08Z")

</div>

**@ ohrenkino:** I used the function (\<CTRL + E\>) with "$meta\_sep(ARTIST,\)" to export the artists of one album.

---

<div class="post-metadata">

### Author: ![kauwelhoner](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/k/9de0a6/32.png) [@kauwelhoner](https://community.mp3tag.de/u/kauwelhoner)
#### Post date: [August 16, 2026, 5:43pm UTC](https://community.mp3tag.de/t/regex-issues-when-rearranging-multivalue-tag/71734/5 "2026-08-16T17:43:40Z")

</div>

This results in a file output.txt like this:

```auto
Toots Thielemans\\Joe Pass\\Niels Henning Ørsted-Pedersen
Toots Thielemans\\Joe Pass\\Niels Henning Ørsted-Pedersen
Toots Thielemans\\Joe Pass\\Niels Henning Ørsted-Pedersen
Toots Thielemans\\Joe Pass\\Niels Henning Ørsted-Pedersen
Toots Thielemans\\Joe Pass\\Niels Henning Ørsted-Pedersen

```

After seding with

sed -E 's/(^|\)([^\]+) ([^\]+)(\|$)/\1\3, \2\4/g' output.txt \> input.txt

input.txt looks like:

```auto
Thielemans, Toots\\Pass, Joe\\Henning Ørsted-Pedersen, Niels
Thielemans, Toots\\Pass, Joe\\Henning Ørsted-Pedersen, Niels
Thielemans, Toots\\Pass, Joe\\Henning Ørsted-Pedersen, Niels
Thielemans, Toots\\Pass, Joe\\Henning Ørsted-Pedersen, Niels
Thielemans, Toots\\Pass, Joe\\Henning Ørsted-Pedersen, Niels

```

The next step was to re-import input.txt with an action (I believe)

```auto
Import text file "$meta_sep(ARTISTSORT,\\)"

```

but right now I'm struggling how to open input.txt ?

@Florian:

Your regex-string solved my problem and I don't even need to export / import the tags to textfiles.

Thank you very much both of you for your support! 🤩

Best Regards

kauwelhoner

---

<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: [August 18, 2026, 5:44pm UTC](https://community.mp3tag.de/t/regex-issues-when-rearranging-multivalue-tag/71734/6 "2026-08-18T17:44:10Z")

</div>

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