# Compliacted regex function

**URL:** https://community.mp3tag.de/t/compliacted-regex-function/13579
**Category:** Support
**Created:** [June 24, 2012, 6:12am UTC](https://community.mp3tag.de/t/compliacted-regex-function/13579 "2012-06-24T06:12:29Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![kiboy6](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/k/d9b06d/32.png) [@kiboy6](https://community.mp3tag.de/u/kiboy6)
#### Post date: [June 24, 2012, 6:12am UTC](https://community.mp3tag.de/t/compliacted-regex-function/13579/1 "2012-06-24T06:12:29Z")

</div>

Hi,

Just wondering if there would be any way to do the following:

When artist field contains two artists separated by " / "

Change artist field to first artist only

Add (feat. + _second artist's name_) to title field.

For example:

Title: Brains Out  
Artist: Caotico / Tove Styrke

--\>

Title : Brains Out (feat. Tove Styrke)  
Artist: Caotico

Would this be possible via a regex?

Thanks so much

---

<div class="post-metadata">

### Author: ![DetlevD](https://community.mp3tag.de/user_avatar/community.mp3tag.de/detlevd/32/123_2.png) [@DetlevD](https://community.mp3tag.de/u/DetlevD)
#### Post date: [June 24, 2012, 6:53am UTC](https://community.mp3tag.de/t/compliacted-regex-function/13579/2 "2012-06-24T06:53:20Z")

</div>

> [@kiboy6](#):
>
> ... Just wondering if there would be any way to do the following:  
> When artist field contains two artists separated by " / "  
> Change artist field to first artist only  
> Add (feat. + _second artist's name_) to title field.  
> For example:  
> Title: Brains Out  
> Artist: Caotico / Tove Styrke  
> --\>  
> Title : Brains Out (feat. Tove Styrke)  
> Artist: Caotico  
> Would this be possible via a regex? Thanks so much

Just answering ...  
No, not by one Regular Expression, because the result of one $regexp function can only directed to one tag-field at once.

But you can apply two actions ...

At first ...  
Filter: **ARTIST MATCHES "^.+?\s/\s.+?$"**  
... or more safe ...  
Filter: "**$len($regexp($regexp(%ARTIST%,'\s/\s','\a'),'[^\a]',))" IS 1**

Then ...  
Action: Format value  
Field: TITLE  
Format string: **$regexp(%TITLE%'==='%ARTIST%,'^(.+?)===.+?\s/\s(.+?)$','$1 (feat. $2)')**  
... or ...  
Format string: **%TITLE%$regexp(%ARTIST%,'^.+?\s/\s(.+?)$',' (feat. $1)')**

Action: Format value  
Field: ARTIST  
Format string: **$regexp(%ARTIST%,'^(.+?)\s/\s.+$','$1')**

DD.20120624.1117.CEST  
Edit.DD.20120625.1710.CEST

---

<div class="post-metadata">

### Author: ![kiboy6](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/k/d9b06d/32.png) [@kiboy6](https://community.mp3tag.de/u/kiboy6)
#### Post date: [June 24, 2012, 7:56am UTC](https://community.mp3tag.de/t/compliacted-regex-function/13579/3 "2012-06-24T07:56:48Z")

</div>

many thanks - that works great.

Being greedy...is there any way to achieve the same without needing the filter?

Ie. make the changes when multiple artists are present but do nothing when there is a single artist.

At the moment if i run your two actions on a mp3 with single artist the actions result in a title like "Back of My Head===Caotico"

Thanks very much for your kind help!

> [@DetlevD](#):
>
> Just answering ...  
> No, not by one Regular Expression, because the result of one $regexp function can only directed to one tag-field at once.
> 
> But you can apply two actions ...  
> Set Filter: **ARTIST MATCHES "^.+?\s/\s.+?$"**
> 
> Action: Format value  
> Field: TITLE  
> Format string: **$regexp(%TITLE%'==='%ARTIST%,'^(.+?)===.+?\s/\s(.+?)$','$1 (feat. $2)')**
> 
> Action: Format value  
> Field: ARTIST  
> Format string: **$regexp(%ARTIST%,'^(.+?)\s/\s.+$','$1')**
> 
> DD.20120624.1117.CEST

---

<div class="post-metadata">

### Author: ![DetlevD](https://community.mp3tag.de/user_avatar/community.mp3tag.de/detlevd/32/123_2.png) [@DetlevD](https://community.mp3tag.de/u/DetlevD)
#### Post date: [June 24, 2012, 9:24am UTC](https://community.mp3tag.de/t/compliacted-regex-function/13579/4 "2012-06-24T09:24:26Z")

</div>

> [@kiboy6](#):
>
> ... At the moment if i run your two actions on a mp3 with single artist the actions result in a title like "Back of My Head===Caotico" ...

This is not surprising, because incorrect application by user generates the error.

> [@kiboy6](#):
>
> many thanks - that works great.  
> Being greedy...is there any way to achieve the same without needing the filter?  
> Ie. make the changes when multiple artists are present but do nothing when there is a single artist. ...

Are you aware of the fact, that doing so every file will be touched, even those, where nothing needs to be changed?

The human will is to be sky-reaching.

You can try these two actions ...  
No Filter.

Action: Format value  
Field: TITLE  
Format string: **$if($eql($len($regexp($regexp(%ARTIST%,'\s/\s','\a'),'[^\a]',)),1),$regexp(%TITLE%'==='%ARTIST%,'^(.+?)===.+?\s/\s(.+?)$','$1 (feat. $2)'),%TITLE%)**  
... or ...  
Format string: **$if($eql($len($regexp($regexp(%ARTIST%,'\s/\s','\a'),'[^\a]',)),1),%TITLE%$regexp(%ARTIST%,'^.+?\s/\s(.+?)$',' (feat. $1)'),%TITLE%)**

Action: Format value  
Field: ARTIST  
Format string: **$if($eql($len($regexp($regexp(%ARTIST%,'\s/\s','\a'),'[^\a]',)),1),$regexp(%ARTIST%,'^(.+?)\s/\s.+$','$1'),%ARTIST%)**

DD.20120624.1323.CEST  
Edit.DD.20120625.1857.CEST

---

<div class="post-metadata">

### Author: ![kiboy6](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/k/d9b06d/32.png) [@kiboy6](https://community.mp3tag.de/u/kiboy6)
#### Post date: [June 25, 2012, 4:49am UTC](https://community.mp3tag.de/t/compliacted-regex-function/13579/5 "2012-06-25T04:49:42Z")

</div>

Well that seems to do the trick perfectly - thanks so much for the incredible regex wizardry.

> [@DetlevD](#):
>
> This is not surprising, because incorrect application by user generates the error.
> 
> Are you aware of the fact, that doing so every file will be touched, even those, where nothing needs to be changed?
> 
> The human will is to be sky-reaching.
> 
> You can try these two actions ...  
> No Filter.
> 
> Action: Format value  
> Field: TITLE  
> Format string: **$if($eql($len($regexp($regexp(%ARTIST%,'\s/\s','\a'),'[^\a]',%DUMMY%)),1),$regexp(%TITLE%'==='%ARTIST%,'^(.+?)===.+?\s/\s(.+?)$','$1 (feat. $2)'),%TITLE%)**
> 
> Action: Format value  
> Field: ARTIST  
> Format string: **$if($eql($len($regexp($regexp(%ARTIST%,'\s/\s','\a'),'[^\a]',%DUMMY%)),1),$regexp(%ARTIST%,'^(.+?)\s/\s.+$','$1'),%ARTIST%)**
> 
> DD.20120624.1323.CEST

---

<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: [February 9, 2026, 12:23pm UTC](https://community.mp3tag.de/t/compliacted-regex-function/13579/6 "2026-02-09T12:23:55Z")

</div>


