# Replace a second instance of a repated word

**URL:** <https://community.mp3tag.de/t/replace-a-second-instance-of-a-repated-word/59102>\
**Category:** Support\
**Created:** [November 18, 2022, 8:35pm UTC](https://community.mp3tag.de/t/replace-a-second-instance-of-a-repated-word/59102 "2022-11-18T20:35:06Z")\
**Posts on this page:** 10\
**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:** [November 18, 2022, 8:35pm UTC](https://community.mp3tag.de/t/replace-a-second-instance-of-a-repated-word/59102/1 "2022-11-18T20:35:06Z")

</div>

I am trying to come up with a rule which would convert the artist field exactly like this:

Above & Beyond & Richard Bedford --\> Above & Beyond Feat. Richard Bedford  
In other words, only the second repeated word (&, in this case) will be converted.  
Is it doable?

---

<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:** [November 18, 2022, 8:41pm UTC](https://community.mp3tag.de/t/replace-a-second-instance-of-a-repated-word/59102/2 "2022-11-18T20:41:01Z")

</div>

Try an action of the type "Format value" for ARTIST  
Format string: `$regexp(%artist%,(.*) & (.*),$1 Feat. $2)`

---

<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:** [November 18, 2022, 8:49pm UTC](https://community.mp3tag.de/t/replace-a-second-instance-of-a-repated-word/59102/3 "2022-11-18T20:49:50Z")

</div>

Worked perfectly, thanks!  
What does (.\*) do?

---

<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:** [November 18, 2022, 8:50pm UTC](https://community.mp3tag.de/t/replace-a-second-instance-of-a-repated-word/59102/4 "2022-11-18T20:50:57Z")

</div>

See the documentation:

> **[Regular Expressions – Mp3tag Documentation](https://docs.mp3tag.de/regex/)**
>
> Documentation on support for regular expressions in Mp3tag. Mp3tag is the universal Tag Editor.

---

<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:** [November 18, 2022, 9:04pm UTC](https://community.mp3tag.de/t/replace-a-second-instance-of-a-repated-word/59102/5 "2022-11-18T21:04:35Z")

</div>

Thanks, still bit too confusing for me but I will try to read deeper into it.

Appreciate your help as always.

---

<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:** [November 18, 2022, 9:09pm UTC](https://community.mp3tag.de/t/replace-a-second-instance-of-a-repated-word/59102/6 "2022-11-18T21:09:13Z")

</div>

`.*` means: any number of characters - and as many as possible. which means any characters up to the last `&`  
the () means: save the string as defined by the pattern in a variable $x.

---

<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:** [November 19, 2022, 12:41am UTC](https://community.mp3tag.de/t/replace-a-second-instance-of-a-repated-word/59102/7 "2022-11-19T00:41:58Z")

</div>

> [@ohrenkino](#):
>
> `$regexp(%artist%,(.*) & (.*),$1 Feat. $2)`

I am now trying to modify this expression to replace the first & in the artist field.  
Example: Zoo Brazil & Wolf & Moon -\> Zoo Brazil Feat. Wolf & Moon  
I tried `$regexp(%artist%,(.*) & (.*),$2 Feat. $1)` and a bunch of different things but can't figure it out.

---

<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:** [November 19, 2022, 12:46am UTC](https://community.mp3tag.de/t/replace-a-second-instance-of-a-repated-word/59102/8 "2022-11-19T00:46:26Z")

</div>

Nevermind, finally figured it out  
`$regexp(%artist%,(.) & (.*),$1 Feat. $2)`

---

<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:** [November 19, 2022, 6:41am UTC](https://community.mp3tag.de/t/replace-a-second-instance-of-a-repated-word/59102/9 "2022-11-19T06:41:11Z")

</div>

> [@tdog](#):
>
> Zoo Brazil & Wolf & Moon -\> Zoo Brazil Feat. Wolf & Moon

Try  
`$regexp(%artist%,(.*?) & (.*),$1 Feat. $2)`

---

<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:** [December 19, 2022, 6:41am UTC](https://community.mp3tag.de/t/replace-a-second-instance-of-a-repated-word/59102/10 "2022-12-19T06:41:15Z")

</div>

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