# Trim everything after a 2 character wildcard

**URL:** https://community.mp3tag.de/t/trim-everything-after-a-2-character-wildcard/67484
**Category:** Support
**Created:** [February 11, 2025, 11:46pm UTC](https://community.mp3tag.de/t/trim-everything-after-a-2-character-wildcard/67484 "2025-02-11T23:46:56Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![wilcoson](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/w/7bcc69/32.png) [@wilcoson](https://community.mp3tag.de/u/wilcoson)
#### Post date: [February 11, 2025, 11:46pm UTC](https://community.mp3tag.de/t/trim-everything-after-a-2-character-wildcard/67484/1 "2025-02-11T23:46:56Z")

</div>

Hello,

I stupidly merged several tags into the album field and am trying to undo that. Using this example:

Tour de Force US 1983\_6992513

"US" being the country code which can vary from album to album, is there an expression that will identify two capitalized characters (any country code) and trim everything after including the country code and the space before it? This is a bit more advanced than I can figure out unfortunately. Any suggestions would be greatly appreciated

Thanks,  
Mike

---

<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: [February 12, 2025, 1:52am UTC](https://community.mp3tag.de/t/trim-everything-after-a-2-character-wildcard/67484/2 "2025-02-12T01:52:53Z")

</div>

Assuming I understood your post correctly, you want

```auto
Tour de Force US 1983_6992513

```

to become `Tour de Force`.

This can be achieved with an action of type Format value  
Field: `ALBUM`  
Format string: `$regexp(%album%,^(.*) '['A-Z']'{2} .*$,$1)`

Here's a visualization of the regular expression:  
 ![grafik](https://community.mp3tag.de/uploads/default/original/3X/e/3/e3e64500e68b5dea874625cd3cb9b4379e01a670.png)

However do note that this might yield unexpected results, should the album contain other instances of 2 capital letters as well (`Live on TV` for example).

---

<div class="post-metadata">

### Author: ![wilcoson](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/w/7bcc69/32.png) [@wilcoson](https://community.mp3tag.de/u/wilcoson)
#### Post date: [February 12, 2025, 2:11am UTC](https://community.mp3tag.de/t/trim-everything-after-a-2-character-wildcard/67484/3 "2025-02-12T02:11:23Z")

</div>

Worked perfectly, thanks so much! I knew there'd be a chance for unintended consequences but this will save me a ton of time over doing it manually. Thanks again

---

<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: [February 12, 2025, 7:52am UTC](https://community.mp3tag.de/t/trim-everything-after-a-2-character-wildcard/67484/4 "2025-02-12T07:52:52Z")

</div>

> [@wilcoson](#):
>
> I knew there'd be a chance for unintended consequences

I suggest to filter your albums first (for your country code for example).  
One of the pitfalls in this case are album names in all uppercase like  
`THIS IS DANGEROUS`  
which would end in  
`THIS`

Or  
`HIT ME HARD AND SOFT`  
would become  
`HIT`

This is not a problem with above regular expression!  
A regular expression just can't tell the difference between two intentional capital letters, such as US or TV and others that are only capitalized for stylistic reasons like IS or ME in the above example.

---

<div class="post-metadata">

### Author: ![wilcoson](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/w/7bcc69/32.png) [@wilcoson](https://community.mp3tag.de/u/wilcoson)
#### Post date: [February 12, 2025, 2:56pm UTC](https://community.mp3tag.de/t/trim-everything-after-a-2-character-wildcard/67484/5 "2025-02-12T14:56:56Z")

</div>

That’s a good point. In my case, all album titles are first letter capitalized via MP3Tag action, e.g “Out Of Our Heads”  
Therefore I should be ok. Anyone else reading this should note the caveats however.

---

<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: [March 14, 2025, 2:57pm UTC](https://community.mp3tag.de/t/trim-everything-after-a-2-character-wildcard/67484/6 "2025-03-14T14:57:02Z")

</div>

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