Need someone who's good with Regular Expressions!

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:

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!

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)".


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:

Anyway, Thanks for that mate! :wink:


Oh I kinda get it, "/b is for boundaries and puts the "/d" (any digit) in it, but I have trouble understanding the $ signs <_<