# Change only specific instance

**URL:** https://community.mp3tag.de/t/change-only-specific-instance/64744
**Category:** Support
**Created:** [May 21, 2024, 3:39pm UTC](https://community.mp3tag.de/t/change-only-specific-instance/64744 "2024-05-21T15:39:32Z")
**Posts on this page:** 13
**Page:** 1

<div class="post-metadata">

### Author: ![cmach1](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/c/46a35a/32.png) [@cmach1](https://community.mp3tag.de/u/cmach1)
#### Post date: [May 21, 2024, 3:39pm UTC](https://community.mp3tag.de/t/change-only-specific-instance/64744/1 "2024-05-21T15:39:32Z")

</div>

Let's say I have a field where there are multiple hyphens, but I only want to change the first one to a /, while keeping the other hyphens as they are. I know a replace action will do it, but the problem is it'll change all of them. What's the code to limit it to only a specific instance?

---

<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: [May 21, 2024, 3:41pm UTC](https://community.mp3tag.de/t/change-only-specific-instance/64744/2 "2024-05-21T15:41:48Z")

</div>

Maybe a regular expression?

Please show us a real existing field with real existing content then we can help you much better.

---

<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: [May 21, 2024, 4:05pm UTC](https://community.mp3tag.de/t/change-only-specific-instance/64744/3 "2024-05-21T16:05:54Z")

</div>

As a first hint: Have a look at Convert\>Tag-Tag for the field (GENRE?)  
Format string: `$regexp(%field%,(.*?) - (.*), $1 / $2)`  
and see whether the preview shows something promising.  
It should be obvious, that you put the real field name instead of %field%.

---

<div class="post-metadata">

### Author: ![cmach1](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/c/46a35a/32.png) [@cmach1](https://community.mp3tag.de/u/cmach1)
#### Post date: [May 21, 2024, 4:44pm UTC](https://community.mp3tag.de/t/change-only-specific-instance/64744/4 "2024-05-21T16:44:33Z")

</div>

The field for this example is %album%.

I want to keep the hyphen between "028" and "Metro" as is, but change the proceeding three hyphens to /.

![4564646](https://community.mp3tag.de/uploads/default/original/3X/4/0/40c838c5ebf761b3680e7b18d27983c46046a84a.jpeg)

---

<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: [May 21, 2024, 4:57pm UTC](https://community.mp3tag.de/t/change-only-specific-instance/64744/5 "2024-05-21T16:57:27Z")

</div>

Try  
Format string: `$regexp($replace('Capitol Hi-Q L-028 - Metro - Light Activity - Toy - Comedy', - , / ),(.*?) / (.*), $1 - $2)`  
 ![grafik](https://community.mp3tag.de/uploads/default/original/3X/2/c/2cb2d20d43a1b714bd2e7203f39d0ec97324be18.png)

---

<div class="post-metadata">

### Author: ![cmach1](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/c/46a35a/32.png) [@cmach1](https://community.mp3tag.de/u/cmach1)
#### Post date: [May 21, 2024, 5:18pm UTC](https://community.mp3tag.de/t/change-only-specific-instance/64744/6 "2024-05-21T17:18:05Z")

</div>

That's very close. Just one thing. Is there a way, in the same string, to delete the spaces around the slashes?

So that section can look like this:  
Metro/Light Activity/Toy/Comedy

---

<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: [May 21, 2024, 5:21pm UTC](https://community.mp3tag.de/t/change-only-specific-instance/64744/7 "2024-05-21T17:21:43Z")

</div>

Replace the blank-slash-blank with just a slash anywhere you find it in the expression.  
As Convert\>Tag-Tag has a preview, you should see the immediate effekt as soon as you edit the expression.

---

<div class="post-metadata">

### Author: ![cmach1](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/c/46a35a/32.png) [@cmach1](https://community.mp3tag.de/u/cmach1)
#### Post date: [May 21, 2024, 5:50pm UTC](https://community.mp3tag.de/t/change-only-specific-instance/64744/8 "2024-05-21T17:50:48Z")

</div>

Maybe I'm not doing something right, but for some reason I can't adjust the spacing around the would-be slashes without it also replacing the first hyphen with a slash, which I want left alone.

I can do a replace action after the conversion to swap out all the blank-slash-blanks with just a slash, but I was hoping it could all be done in one step.

---

<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: [May 21, 2024, 5:55pm UTC](https://community.mp3tag.de/t/change-only-specific-instance/64744/9 "2024-05-21T17:55:01Z")

</div>

Try  
`$regexp($replace('Capitol Hi-Q L-028 - Metro - Light Activity - Toy - Comedy', - ,/),(.*?)/(.*),$1 - $2)`  
whch leads to:  
`Capitol Hi-Q L-028 - Metro/Light Activity/Toy/Comedy`

---

<div class="post-metadata">

### Author: ![cmach1](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/c/46a35a/32.png) [@cmach1](https://community.mp3tag.de/u/cmach1)
#### Post date: [May 21, 2024, 5:59pm UTC](https://community.mp3tag.de/t/change-only-specific-instance/64744/10 "2024-05-21T17:59:47Z")

</div>

That did it! Thank you!

Is there a tutorial or information database on here that explains what all these symbols represent? I feel like I could figure out this more easily if I knew the right symbols to use for a given situation.

---

<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: [May 21, 2024, 6:01pm UTC](https://community.mp3tag.de/t/change-only-specific-instance/64744/11 "2024-05-21T18:01:05Z")

</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: ![LyricsLover](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/l/c6cbf5/32.png) [@LyricsLover](https://community.mp3tag.de/u/LyricsLover)
#### Post date: [May 21, 2024, 6:40pm UTC](https://community.mp3tag.de/t/change-only-specific-instance/64744/12 "2024-05-21T18:40:34Z")

</div>

> [@cmach1](#):
>
> Is there a tutorial or information database on here that explains what all these symbols represent?

You can copy & paste such expressions to regular expression test websites like [regex101.com](https://regex101.com/)

They give you an explanation for `(.*?)/(.*)` like this:

 ![image](https://community.mp3tag.de/uploads/default/original/3X/e/7/e7596db04f398499c37d4d6ecdccb7a8f2e836e2.png)

The 1st Capturing Group is represented by `$1`  
The 2nd Capturing Group is represented by `$2`  
In the above example `$1 - $2`, there is a space, a hyphen and a space between the ouptut of `$1` and `$2`  
(dividing `Capitol Hi-Q L-028` from `Metro/Light Activity/Toy/Comedy`)

The regular expression will be combined with a `$replace` command, where all space hyphen will be replaced with as slash.

---

<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: [June 20, 2024, 6:40pm UTC](https://community.mp3tag.de/t/change-only-specific-instance/64744/13 "2024-06-20T18:40:39Z")

</div>

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