# Help replacing characters based on how many times it appears

**URL:** <https://community.mp3tag.de/t/help-replacing-characters-based-on-how-many-times-it-appears/13022>\
**Category:** Support\
**Created:** [January 29, 2012, 9:29pm UTC](https://community.mp3tag.de/t/help-replacing-characters-based-on-how-many-times-it-appears/13022 "2012-01-29T21:29:37Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![vphreeze](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/v/7ba0ec/32.png) [@vphreeze](https://community.mp3tag.de/u/vphreeze)\
**Post date:** [January 29, 2012, 9:29pm UTC](https://community.mp3tag.de/t/help-replacing-characters-based-on-how-many-times-it-appears/13022/1 "2012-01-29T21:29:37Z")

</div>

ok, i guess the easiest way to explain this is just explain what results i want. in the composer field, if there is a single "/", i want it converted to " & " (this I can do), but if there is more than one "/" i want to change them to ", " except the last one, which would be " & "

example 1:  
Tom/John  
Tom & John

example 2:  
Tom/John/Larry/Bill  
Tom, John, Larry & Bill

---

<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:** [January 30, 2012, 3:31pm UTC](https://community.mp3tag.de/t/help-replacing-characters-based-on-how-many-times-it-appears/13022/2 "2012-01-30T15:31:04Z")

</div>

Probably DetlevD knows how to do this in one go ... I can only think of an action group that executes 2 replace actions:  
the first is a "Replace with regular expression" and the format strings:  
(._)/(._)  
Replace with:  
$1 & $2  
(as it is "non-greedy" it only replaces the last slash)  
and the second is an action of the type "Replace" (no regular expression)  
with search string  
/  
and replace string  
,\_  
(where the \_ represents the blank)  
The last action does nothing if there is nothing to replace.

---

<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:** [January 8, 2015, 8:06pm UTC](https://community.mp3tag.de/t/help-replacing-characters-based-on-how-many-times-it-appears/13022/3 "2015-01-08T20:06:39Z")

</div>

> [@vertigo phreeze](#):
>
> ... in the composer field, if there is a single "/", i want it converted to " & " (this I can do), but if there is more than one "/" i want to change them to ", " except the last one, which would be " & " ...  
> ... example 1:  
> Tom/John  
> Tom & John  
> ... example 2:  
> Tom/John/Larry/Bill  
> Tom, John, Larry & Bill

For both examples ...

Begin Action Group **Test2015#20150108.Itemlist.Replace.SlashToCommaOrAmpersand** 

Action #1  
_Actiontype 5:_ **Format value**  
_Field \_\_\_\_\_\_:_ **COMPOSER**  
_Formatstring:_ **$ifgreater($sub($len(%COMPOSER%),$len($replace(%COMPOSER%,'/',))),0,$replace(%COMPOSER%,'/',', '),%COMPOSER%)**

 

Action #2  
_Actiontype 5:_ **Format value**  
_Field \_\_\_\_\_\_:_ **COMPOSER**  
_Formatstring:_ **$ifgreater($sub($len(%COMPOSER%),$len($replace(%COMPOSER%,', ',))),0,$left(%COMPOSER%,$sub($strrchr(%COMPOSER%,', '),1))' & '$cutLeft(%COMPOSER%,$add($strrchr(%COMPOSER%,', '),1)),%COMPOSER%)**

 

End Action Group **Test2015#20150108.Itemlist.Replace.SlashToCommaOrAmpersand** (2 Actions)

 

... or ...

 Begin Action Group **Test2015#20150108.Itemlist.Replace.SlashToCommaAmpersand (1)** 

Action #1  
_Actiontype 5:_ **Format value**  
_Field \_\_\_\_\_\_:_ **COMPOSER**  
_Formatstring:_ **$regexp($regexp(%COMPOSER%,'/',', '),'(.+), (.+)','$1 & $2')**

 

End Action Group **Test2015#20150108.Itemlist.Replace.SlashToCommaAmpersand (1)** (1 Action)

 

DD.20150109.0907.CET

---

<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/help-replacing-characters-based-on-how-many-times-it-appears/13022/4 "2026-02-09T12:23:37Z")

</div>

Closed on February 9, 2026, 12:23pm UTC


