# RegEx snippet: Replace part of the title

**URL:** https://community.mp3tag.de/t/regex-snippet-replace-part-of-the-title/63328
**Category:** Support
**Created:** [January 5, 2024, 12:47pm UTC](https://community.mp3tag.de/t/regex-snippet-replace-part-of-the-title/63328 "2024-01-05T12:47:29Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![1stein](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/1/d9b06d/32.png) [@1stein](https://community.mp3tag.de/u/1stein)
#### Post date: [January 5, 2024, 12:47pm UTC](https://community.mp3tag.de/t/regex-snippet-replace-part-of-the-title/63328/1 "2024-01-05T12:47:29Z")

</div>

Thanks to the good documentation, I quickly found out about **Actions** and used **Replace with regular expression**. Now that the thread [Regular Expressions](https://community.mp3tag.de/t/regular-expressions/521) is closed, I'm sharing my expression in this topic.

A couple of files have this very long track title, where I am only interested in the words after the first colon and space ": " and before the pipe "|".

> Der Herr der Ringe (30/30): **Ein Zeitalter geht zu Ende** | J.R.R. Tolkien: Der Herr der Ringe – Fantasy-Hörspiel-Klassiker (25.12.2022)

My action looks like this:  
**Field:** TITLE  
**Regular expression:** `(.*\: )(.*)( \|.*)`  
**Replace with:** $2

**$2** refers to the second capture group, which is the actual title of the track. You can see a visual example at [regex101](https://regex101.com/r/HKKwpe/2) for better understanding. At least it helped me a lot 😅

---

<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 9, 2024, 1:20pm UTC](https://community.mp3tag.de/t/regex-snippet-replace-part-of-the-title/63328/2 "2024-01-09T13:20:02Z")

</div>

> [@1stein](#):
>
> where I am only interested in the words after the first colon and space ": " and before the pipe "|".

As these are nice unique identifiers you could also use an action of the type "Guess value":  
Source: %title%  
Target format string: `%dummy%: %title% |%dummy%`

I would use the regular expression if there are no real unique single character constants but variable types e.g. there would not have been a colon but only the number:  
`Der Herr der Ringe 30/30 Ein Zeitalter geht zu Ende | J.R.R. Tolkien: Der Herr der Ringe – Fantasy-Hörspiel-Klassiker (25.12.2022)`  
then a \d+ to indicate a variable number would have separated the leading string from the rest.

But your solution is just as nice and there are a number of ways to skin a cat.

---

<div class="post-metadata">

### Author: ![Casual\_Tea](https://community.mp3tag.de/user_avatar/community.mp3tag.de/casual_tea/32/18886_2.png) [@Casual\_Tea](https://community.mp3tag.de/u/Casual_Tea)
#### Post date: [January 9, 2024, 8:11pm UTC](https://community.mp3tag.de/t/regex-snippet-replace-part-of-the-title/63328/3 "2024-01-09T20:11:57Z")

</div>

I usually go the other way and try to be as specific as possible (your guess value string is specific as well, just to be clear). That's why my latest regexes always include ^ and $ and match the entire string I aim to edit or nothing at all to avoid any false matches. I still visually inspect all the results anyhow but maybe I'm just paranoid.

For example when I standardized 93 bruce springsteen concert recordings yesterday, the date part of the album tags was all over the place.  
The naming variations included:  
2023-12-24 venue, city, country  
2023/12/24 venue, city, country  
2023.12.24 venue, city, country  
12/24/23 venue, city, country

To correct the last case `12/24/23...` I matched `(\d{2})/(\d{2})/(\d{2})(.*)` and replaced it with `20$3-$1-$2$4` initially, but that also matches `2023/12/24...` partially, `23/12/24...` to be exact.

While my correction works fine for `12/24/23...`, yielding `2023-12-24...` as expected (all concerts were from 2000 and newer, otherwise the hardcoded 20 would not work), it also changed `2023/12/24...` to `202024-23-12...` or some nonesense like that.  
Limiting the regex with ^ and $ to `^(\d{2})/(\d{2})/(\d{2})(.*)$` prevented that false match from happening and allowed me to combine all correction combinations into 2 action groups. One with a hardcoded 19 for concerts from before the year 2000 and one with a hardcoded 20 for newer releases.

> [@ohrenkino](#):
>
> But your solution is just as nice and there are a number of ways to skin a cat.

That is true. When something is consistent and follows a clearly separated pattern like the example from @1stein, "Guess value" works just fine and is usually quicker unless you live and breathe regex.

---

<div class="post-metadata">

### Author: ![1stein](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/1/d9b06d/32.png) [@1stein](https://community.mp3tag.de/u/1stein)
#### Post date: [January 9, 2024, 9:35pm UTC](https://community.mp3tag.de/t/regex-snippet-replace-part-of-the-title/63328/4 "2024-01-09T21:35:20Z")

</div>

Today I learned about „Guess Value“, I thank you both!

---

<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:30pm UTC](https://community.mp3tag.de/t/regex-snippet-replace-part-of-the-title/63328/5 "2026-02-09T12:30:13Z")

</div>


