# Need someone who's good with Regular Expressions!

**URL:** <https://community.mp3tag.de/t/need-someone-whos-good-with-regular-expressions/16994>\
**Category:** Support\
**Created:** [June 24, 2015, 3:12pm UTC](https://community.mp3tag.de/t/need-someone-whos-good-with-regular-expressions/16994 "2015-06-24T15:12:16Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![damnthemachine](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/d/54ee81/32.png) [@damnthemachine](https://community.mp3tag.de/u/damnthemachine)\
**Post date:** [June 24, 2015, 3:12pm UTC](https://community.mp3tag.de/t/need-someone-whos-good-with-regular-expressions/16994/1 "2015-06-24T15:12:16Z")

</div>

So, I've been messing around and trying to do something with mp3tag for a while now, but my understanding of scripting and all the different Syntax is minimal, so I came here to ask for a tutor for this one.

So here is what I am trying to do:  
I've got albums that have no year assigned to them, but the folders they are in do have the years in the folder name.

For Example:  
_"...\Tool(1993)Undertow"_

So what I was trying to do is use a **Regular Expression** to get the year out of the **%\_directory%** and fill it into the Year field. Something like this:

```
Format value "YEAR": %_directory%
Regular expression "YEAR": "[^0-9]" -> ""

```

And that's all good until I get an album that has digits in the actual name, something like this:  
_"...\Tool(2006) 10,000 Days"_

What would happen is that it would take all the numbers and throw them into the Year field like "200610000" and that's obviously not very helpful. Again I know I could do it all manually but I am curious here to understand it better, and hey what's the whole point of the software for if I'm gonna end up changing stuff manually.

Anyway, hopefully someone is willing to tutor me on this one. Thanks!

---

<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:** [June 24, 2015, 3:23pm UTC](https://community.mp3tag.de/t/need-someone-whos-good-with-regular-expressions/16994/2 "2015-06-24T15:23:49Z")

</div>

> [@DamnTheMachine](#):
>
> ... the folders they are in do have the years in the folder name.  
> For Example:  
> _"...\Tool(1993)Undertow"_  
> So what I was trying to ... get the year out of the **%\_directory%** and fill it into the Year field. ...

Action: Format value  
Field: YEAR  
Formatstring: **$regexp(%\_directory%,'^._\b(\d\d\d\d)\b._$','$1')**  
... this will detect ... " 1234 " or "(1234)" or "{1234}" ...  
... or ...  
Formatstring: **$regexp(%\_directory%,'^._((\d\d\d\d))._$','$1')**  
... this will detect only ... "(1234)".

DD.20150624.1936.CEST

---

<div class="post-metadata">

**Author:** ![damnthemachine](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/d/54ee81/32.png) [@damnthemachine](https://community.mp3tag.de/u/damnthemachine)\
**Post date:** [June 24, 2015, 3:31pm UTC](https://community.mp3tag.de/t/need-someone-whos-good-with-regular-expressions/16994/3 "2015-06-24T15:31:35Z")

</div>

> [@DetlevD](#):
>
> Action: Format value  
> Field: YEAR  
> Formatstring: **$regexp(%\_directory%,'^._\b(\d\d\d\d)\b._$','$1')**
> 
> DD.20150624.1923.CEST

That was quick and freakin' awesome! It worked perfectly, and that's alot of stuff in one code...  
Wish I knew what it actually does... ![:rolleyes:](https://community.mp3tag.de/uploads/default/original/1X/3a79e8b0b7d169b30216785521d7c6f4f895c421.gif ":rolleyes:")

Anyway, Thanks for that mate! 😉

**EDIT:**

Oh I kinda get it, "/b is for boundaries and puts the "/d" (any digit) in it, but I have trouble understanding the $ signs ![<_<](https://community.mp3tag.de/uploads/default/original/1X/5996dbb474c88b8f9fc49f09dc3858d081055a2d.gif "<\_<")

---

<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:25pm UTC](https://community.mp3tag.de/t/need-someone-whos-good-with-regular-expressions/16994/4 "2026-02-09T12:25:44Z")

</div>

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


