# Rare substitution in filename

**URL:** https://community.mp3tag.de/t/rare-substitution-in-filename/14102
**Category:** Support
**Created:** [November 9, 2012, 10:49pm UTC](https://community.mp3tag.de/t/rare-substitution-in-filename/14102 "2012-11-09T22:49:22Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![ykeyke](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/y/d26b3c/32.png) [@ykeyke](https://community.mp3tag.de/u/ykeyke)
#### Post date: [November 9, 2012, 10:49pm UTC](https://community.mp3tag.de/t/rare-substitution-in-filename/14102/1 "2012-11-09T22:49:22Z")

</div>

Hi people,

Manipulating RegEx, I had come into one that I don't know how to solve: I need to remove '-' and make some substitutions into a file name, I've done it using the format value with the $right, $left and so, but I'd like to do it using the RegEx, as it suits more my purposes, here comes the issue:

Original Filename:  
123-456 A file to change version 123.123 201145-63 **(20**25 **-** 36 **-** 87 **-** 833)

Final Filename:  
123-456 A file to change version 123.123 201145-63 **(-**253687833)

My capture expression is:  
^(.+)\s((\d\d\d\d-\d\d-\d\d-\d\d\d))$

But my replace:  
$1 (-$2$3$4$5)

gives:  
123-456 A file to change version 123.123 201145-63 (-2025-36-87-833$3$4$5)

From this, I see that only spaces serves as delimiter, **no way to definite others ???**

I don't know **how to make disappear the '-' between parenthesis, and at the same time substitute the first two digit into with a '-'**... and obviously let the rest of filename untouched ??

Thanks for your patience.

---

<div class="post-metadata">

### Author: ![stevehero](https://community.mp3tag.de/user_avatar/community.mp3tag.de/stevehero/32/337_2.png) [@stevehero](https://community.mp3tag.de/u/stevehero)
#### Post date: [November 10, 2012, 12:34am UTC](https://community.mp3tag.de/t/rare-substitution-in-filename/14102/2 "2012-11-10T00:34:42Z")

</div>

> [@ykeyke](#):
>
> I don't know **how to make disappear the '-' between parenthesis, and at the same time substitute the first two digit into with a '-'**... and obviously let the rest of filename untouched ??

First of all you have a ^ anchor to your regexp which there is no call. Tip is to start at the back and work your way backwards where you need to concentrate your attention. And also use the feature to make sure your doing it right. I know it doesn't have the \_FILENAME but you can substitute it for something else for the time being.

![](https://community.mp3tag.de/uploads/default/original/2X/b/bb082a6118b1c7ecd5304e0635a638da22984997.jpg)

**Here's something that works:**

Begin Action Group **\_Script Test#TEST**

**Action #1** _Actiontype 5:_ **Format value** _Field \_\_\_\_\_\_:_ **\_FILENAME** _Formatstring:_ **$regexp** ( **%\_filename%** ,**'(.+\()\d{2}(\d{2})-(\d+)-(\d+)-(\d+\))$**, **'$1-$2$3$4$5'** )

End Action Group **\_Script Test#TEST** (1 Action)

**Study this to see how the regexp works and if you have any questions please ask**

 ![](https://community.mp3tag.de/uploads/default/original/2X/c/ca38b7424f9b09c5dfdcfcd9008e8cb77d5288fa.jpg)  

![](https://community.mp3tag.de/uploads/default/original/2X/b/bb082a6118b1c7ecd5304e0635a638da22984997.jpg)

 ![](https://community.mp3tag.de/uploads/default/original/2X/c/ca38b7424f9b09c5dfdcfcd9008e8cb77d5288fa.jpg)

---

<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: [November 10, 2012, 2:54am UTC](https://community.mp3tag.de/t/rare-substitution-in-filename/14102/3 "2012-11-10T02:54:09Z")

</div>

> [@ykeyke](#):
>
> ... Original Filename:  
> 123-456 A file to change version 123.123 201145-63 **(20**25 **-** 36 **-** 87 **-** 833)  
> Final Filename:  
> 123-456 A file to change version 123.123 201145-63 **(-**253687833)

**$regexp(%\_FILENAME%,'^(.+)\s\(\d\d(\d\d)-(\d\d)-(\d\d)-(\d\d\d)\)$','$1 (-$2$3$4$5)')**

DD.20121110.0451.CET

---

<div class="post-metadata">

### Author: ![ykeyke](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/y/d26b3c/32.png) [@ykeyke](https://community.mp3tag.de/u/ykeyke)
#### Post date: [November 10, 2012, 7:10am UTC](https://community.mp3tag.de/t/rare-substitution-in-filename/14102/4 "2012-11-10T07:10:35Z")

</div>

Woow, that's it. It works fine, so the secret was in the parenthesis.  
Thank you stevehero and DetlevD

---

<div class="post-metadata">

### Author: ![ykeyke](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/y/d26b3c/32.png) [@ykeyke](https://community.mp3tag.de/u/ykeyke)
#### Post date: [November 11, 2012, 2:32pm UTC](https://community.mp3tag.de/t/rare-substitution-in-filename/14102/5 "2012-11-11T14:32:05Z")

</div>

> [@stevehero](#):
>
> First of all you have a ^ anchor to your regexp **which there is no call. Tip is to start at the back and work your way backwards where you need to concentrate your attention**. And also use the feature to make sure your doing it right. I know it doesn't have the \_FILENAME but you can substitute it for something else for the time being.

Excuse me Stevehero, can you explain me a little bit the related with the caret anchor. I was reading the related article in [http://www.regular-expressions.info/anchors.html](http://www.regular-expressions.info/anchors.html) and wikipedia, but didn't find my way out with the "Tip" you suggest me... How can I start from the back ? and, the ^ and $ weren't necessary to definite a string where we are working ??? I take notice that none of the solution you give me was using those anchors !!!

Thanks

---

<div class="post-metadata">

### Author: ![stevehero](https://community.mp3tag.de/user_avatar/community.mp3tag.de/stevehero/32/337_2.png) [@stevehero](https://community.mp3tag.de/u/stevehero)
#### Post date: [November 11, 2012, 3:08pm UTC](https://community.mp3tag.de/t/rare-substitution-in-filename/14102/6 "2012-11-11T15:08:01Z")

</div>

> [@ykeyke](#):
>
> Excuse me Stevehero, can you explain me a little bit the related with the caret anchor. I was reading the related article in [http://www.regular-expressions.info/anchors.html](http://www.regular-expressions.info/anchors.html) and wikipedia, but didn't find my way out with the "Tip" you suggest me... How can I start from the back ? and, the ^ and $ weren't necessary to definite a string where we are working ??? I take notice that none of the solutions you give me both you and DetlevD was using those anchors !!!
> 
> Thanks

With an expression like this you can use the ^ anchor because you want to match the start of the string and the end also.

Begin Action Group **\_Script Test#TEST**

**Action #1** _Actiontype 5:_ **Format value** _Field \_\_\_\_\_\_:_ **\_FILENAME** _Formatstring:_ **$regexp(%\_filename%,'^(\d{3}-\d{3}.+\()\d{2}(\d{2})-(\d+)-(\d+)-(\d+\))$,'$1-$2$3$4$5')**

End Action Group **\_Script Test#TEST** (1 Action)

**Will match:**  
123-456 A file to change version 123.123 201145-63 (2025-36-87-833)

**Won't match:**  
A file to change version 123.123 201145-63 (2025-36-87-833)

See attached for breakdown of regexp.

 ![](https://community.mp3tag.de/uploads/default/original/2X/c/cf3928ea2e2417e73ec237a6c1a09985cfbb1806.jpg)  

When using .+ which means any character any number of times at the start of the regexp when using the $ anchor it is irrelevant is all I'm saying and is not required.

**The solution I pasted in the 1st post messed up and has been doing that for some time now. I will edit it to suit. It seems to take out the $ sign.**

 

Anyone else have this problem?

 ![](https://community.mp3tag.de/uploads/default/original/2X/c/cf3928ea2e2417e73ec237a6c1a09985cfbb1806.jpg)

---

<div class="post-metadata">

### Author: ![ykeyke](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/y/d26b3c/32.png) [@ykeyke](https://community.mp3tag.de/u/ykeyke)
#### Post date: [November 11, 2012, 3:34pm UTC](https://community.mp3tag.de/t/rare-substitution-in-filename/14102/7 "2012-11-11T15:34:10Z")

</div>

It's odd, the solution of DetlevD use both ^ and $, yours stevehero, in the first post (just edited) only $ at the final, however I try also using none of them, and it works also, what a mess ?!! All three possibilities do the job !!! I can't see the role !

---

<div class="post-metadata">

### Author: ![ykeyke](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/y/d26b3c/32.png) [@ykeyke](https://community.mp3tag.de/u/ykeyke)
#### Post date: [November 11, 2012, 3:55pm UTC](https://community.mp3tag.de/t/rare-substitution-in-filename/14102/8 "2012-11-11T15:55:56Z")

</div>

However, something like:

$regexp(%\_filename%,'(\d{3}-\d{3})^(.+()\d{2}(\d{2})-(\d+)-(\d+)-(\d+))$,'$1-$2$3$4$5')

didn't work to change:  
123-456 A file to change version 123.123 201145-63 (2025-36-87-833)

into:  
A file to change version 123.123 201145-63 (-253687833)

---

<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: [November 11, 2012, 4:02pm UTC](https://community.mp3tag.de/t/rare-substitution-in-filename/14102/9 "2012-11-11T16:02:45Z")

</div>

> [@ykeyke](#):
>
> It's odd, the solution of DetlevD use both ^ and $, ...

I always try to describe a regex mask as complete as possible, that gives more reliability and robustness against outliers in the abundance of the many possible different input data.

DD.20121111.1800.CET

---

<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: [November 11, 2012, 4:04pm UTC](https://community.mp3tag.de/t/rare-substitution-in-filename/14102/10 "2012-11-11T16:04:43Z")

</div>

> [@ykeyke](#):
>
> However, something like:  
> $regexp(%\_filename%,'(\d{3}-\d{3})^(.+()\d{2}(\d{2})-(\d+)-(\d+)-(\d+))$,'$1-$2$3$4$5')  
> didn't work ...

_Your example is bad regex syntax._

This should work ...  
From:  
123-456 A file to change version 123.123 201145-63 (2025-36-87-833)  
To:  
A file to change version 123.123 201145-63 (-253687833)

**$regexp(%TEST%,'^\d\d\d-\d\d\d\s(.+)\s\(\d\d(\d\d)-(\d\d)-(\d\d)-(\d\d\d)\)$','$1 (-$2$3$4$5)')** 

**```
                            <!--coloro:#000000--><span style="color:#000000"><!--/coloro--> ~~~~~~~~~~  ~~~~~~~~~~~~  ~~~~~~~~ <!--colorc--></span><!--/colorc-->
                            <!--coloro:#000000--><span style="color:#000000"><!--/coloro-->$1 <!--colorc--></span><!--/colorc--> <!--coloro:#000000--><span style="color:#000000"><!--/coloro-->$2 <!--colorc--></span><!--/colorc--> <!--coloro:#000000--><span style="color:#000000"><!--/coloro-->$3 <!--colorc--></span><!--/colorc--> <!--coloro:#000000--><span style="color:#000000"><!--/coloro-->$4 <!--colorc--></span><!--/colorc--> <!--coloro:#000000--><span style="color:#000000"><!--/coloro-->$5<!--colorc--></span><!--/colorc--></b><!--fontc--></span><!--/fontc--><!--sizec--></span><!--/sizec-->**

**```**

 

DD.20121111.1841.CET

---

<div class="post-metadata">

### Author: ![ykeyke](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/y/d26b3c/32.png) [@ykeyke](https://community.mp3tag.de/u/ykeyke)
#### Post date: [November 11, 2012, 4:43pm UTC](https://community.mp3tag.de/t/rare-substitution-in-filename/14102/11 "2012-11-11T16:43:28Z")

</div>

Thanks DetlevD,

The three suggestions works finely, but when I tried:

$regexp(%\_filename%,'(\d{3}-\d{3})^(.+()\d{2}(\d{2})-(\d+)-(\d+)-(\d+))$,'$1-$2$3$4$5')

it was using the fact that ^ defines the start of a string so with this I was hoping to change:

123-456 A file to change version 123.123 201145-63 (2025-36-87-833)

into:

A file to change version 123.123 201145-63 (-253687833)

So I considered that all the job will concentrate only on the string between ^ and $, am I right ? It's to understand the functionalities of those two anchors. Continuing the learning process...

---

<div class="post-metadata">

### Author: ![stevehero](https://community.mp3tag.de/user_avatar/community.mp3tag.de/stevehero/32/337_2.png) [@stevehero](https://community.mp3tag.de/u/stevehero)
#### Post date: [November 11, 2012, 4:51pm UTC](https://community.mp3tag.de/t/rare-substitution-in-filename/14102/12 "2012-11-11T16:51:43Z")

</div>

> [@ykeyke](#):
>
> However, something like:
> 
> $regexp(%\_filename%,'(\d{3}-\d{3})^(.+()\d{2}(\d{2})-(\d+)-(\d+)-(\d+))$,'$1-$2$3$4$5')
> 
> didn't work to change:  
> 123-456 A file to change version 123.123 201145-63 (2025-36-87-833)
> 
> into:  
> A file to change version 123.123 201145-63 (-253687833)

You misunderstood... it will only match not change anything... We are only concentrating on the '**^(\d{3}-\d{3}.+()\d{2}(\d{2})-(\d+)-(\d+)-(\d+))** part of the **$regexp** for the moment.

Considering **^\d{3}-\d{3}** is added to the script to insure proper matching at the start of the script **.** The **(** is now moved from its previous position at **.+** to the start to capture the beginning of the text string thus leave the exact same **$1-$2$3$4$5** in the replace part of the **$regexp**

**But if I understand correctly you want to change:**  
_123-456 A file to change version 123.123 201145-63 (2025-36-87-833)_

**into:**  
_A file to change version 123.123 201145-63 (-253687833)_

Begin Action Group **\_Script Test#TEST**

**Action #1** _Actiontype 5:_ **Format value** _Field \_\_\_\_\_\_:_ **\_FILENAME** _Formatstring:_ **$regexp(%\_filename%,'^\d{3}-\d{3}\s+(.+\()\d{2}(\d{2})-(\d+)-(\d+)-(\d+\))$,'$1-$2$3$4$5')**

End Action Group **\_Script Test#TEST** (1 Action)

**Screen-shot of regexp breakdown**

 ![](https://community.mp3tag.de/uploads/default/original/2X/1/19c09439ebdf6ccde331ceaf3255bfa76c623b77.jpg)  

 ![](https://community.mp3tag.de/uploads/default/original/2X/1/19c09439ebdf6ccde331ceaf3255bfa76c623b77.jpg)

---

<div class="post-metadata">

### Author: ![ykeyke](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/y/d26b3c/32.png) [@ykeyke](https://community.mp3tag.de/u/ykeyke)
#### Post date: [November 11, 2012, 5:05pm UTC](https://community.mp3tag.de/t/rare-substitution-in-filename/14102/13 "2012-11-11T17:05:31Z")

</div>

> [@stevehero](#):
>
> Considering **^\d{3}-\d{3}** is added to the script to insure proper matching at the start of the script **.** The **(** is now moved from its previous position at **.+** to the start to capture the beginning of the text string thus leave the exact same **$1-$2$3$4$5** in the replace part of the **$regexp**

So, am I right when I say that only the parenthesis mark the $1, $2,... parts and ^ and $ mark the start and end of a string, and had no functionality on the action of a regexp ???  
So, if I have a text with, say, three phrases, and I want to work on the second phrase, I must put ^ and $ at start and end of text, but do the job only on $2, $3, $4, $5, considering that $1 and $6 defines the 1st and 3rd phrases ???

Your suggestion works, by the way, stevehero 😆

---

<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: [November 11, 2012, 5:10pm UTC](https://community.mp3tag.de/t/rare-substitution-in-filename/14102/14 "2012-11-11T17:10:38Z")

</div>

> [@ykeyke](#):
>
> ... So I considered that all the job will concentrate only on the string between ^ and $, am I right ? It's to understand the functionalities of those two anchors. Continuing the learning process...

Read there about anchors ...  
[http://www.regular-expressions.info/anchors.html](http://www.regular-expressions.info/anchors.html)

Hm, how to say it in other words?  
Maybe ...  
... without any anchor: floating.  
... with anchors: lashed.

Without any anchor a regex is allowed to float over a given string and can try to match at any position where ever possible.  
A 'floating' regex can create a list of reoccurring matches.  
A 'lashed' regex is only allowed to work at a fixed position or in a destinated area, giving sometimes a predictable number of matches.

I beg your pardon, regex specialists in the world, please forgive me for my flowery description.

DD.20121111.1907.CET

---

<div class="post-metadata">

### Author: ![ykeyke](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/y/d26b3c/32.png) [@ykeyke](https://community.mp3tag.de/u/ykeyke)
#### Post date: [November 11, 2012, 5:38pm UTC](https://community.mp3tag.de/t/rare-substitution-in-filename/14102/15 "2012-11-11T17:38:23Z")

</div>

> [@DetlevD](#):
>
> Without any anchor a regex is allowed to float over a given string and can try to match at any position where ever possible.  
> A 'floating' regex can create a list of reoccurring matches.  
> A 'lashed' regex is only allowed to work at a fixed position or in a destinated area, giving sometimes a predictable number of matches.

So DetlevD, if I am right, and continuing with the same 'modified' example, a filename like:

123-456 A file to change version 123.123 201145-63 (2025-36-87-833) 123-456 A file to change version 123.123 201145-63 (2025-36-87-833).mp3

with anchors, must give:

123-456 A file to change version 123.123 201145-63 (2025-36-87-833) 123-456 A file to change version 123.123 201145-63 (-253687833).mp3

and without, must give:

123-456 A file to change version 123.123 201145-63 (-253687833) 123-456 A file to change version 123.123 201145-63 (-253687833).mp3 (it isn't the case, I get the same as with anchors)

Or it's just I fantasying ?? ![:w00t:](https://community.mp3tag.de/uploads/default/original/1X/cb01eca72fe9339ff6f3ec9f1e3c5fe002be0f0a.gif ":w00t:")

---

<div class="post-metadata">

### Author: ![stevehero](https://community.mp3tag.de/user_avatar/community.mp3tag.de/stevehero/32/337_2.png) [@stevehero](https://community.mp3tag.de/u/stevehero)
#### Post date: [November 11, 2012, 5:56pm UTC](https://community.mp3tag.de/t/rare-substitution-in-filename/14102/16 "2012-11-11T17:56:47Z")

</div>

> [@ykeyke](#):
>
> So, am I right when I say that only the parenthesis mark the $1, $2,... parts and ^ and $ mark the start and end of a string, and had no functionality on the action of a regexp ???  
> So, if I have a text with, say, three phrases, and I want to work on the second phrase, I must put ^ and $ at start and end of text, but do the job only on $2, $3, $4, $5, considering that $1 and $6 defines the 1st and 3rd phrases ???
> 
> Your suggestion works, by the way, stevehero 😆

Of course **^** and $ have functionality but your original post didn't require a ^ because there was an anchor $ at the end and with a .+ at the start to capture all the characters anyway which meant the ^ had no relevance when using the .+ because it was going to go back to the start regardless of it there or not.

On the other hand (couple of post on) you wanted 3 digits a - and 3 more digits and whitespace matched at the start of the string.

So it only made sense to anchor the start also like: **^\d{3}-\d{3}\s+**

If you study the attached image in my previous post you can see exactly how the captures work. They are highlighted green in the left and top window.

---

<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: [November 11, 2012, 7:28pm UTC](https://community.mp3tag.de/t/rare-substitution-in-filename/14102/17 "2012-11-11T19:28:35Z")

</div>

> [@ykeyke](#):
>
> ... Or it's just I fantasying ??

There are are some links regarding regular expressions ...

Einstieg in die Welt der Regulären Ausdrücke siehe dort ...  
[http://zmievski.org/c/dl.php?file=talks/co...egex-clinic.pdf](http://zmievski.org/c/dl.php?file=talks/confoo-2010/regex-clinic.pdf)

Wikipedia ...  
[http://de.wikipedia.org/wiki/Regul%C3%A4rer\_Ausdruck](http://de.wikipedia.org/wiki/Regul%C3%A4rer_Ausdruck)

Regular Expression Basic Syntax Reference ...  
[http://www.regular-expressions.info/reference.html](http://www.regular-expressions.info/reference.html)

Regular Expression Tutorial ...  
[http://www.regular-expressions.info/tutorial.html](http://www.regular-expressions.info/tutorial.html)

Mp3tag Manual ...  
[https://docs.mp3tag.de/actions/replace-regexp](https://docs.mp3tag.de/actions/replace-regexp)

Mp3tag Examples ...  
[/t/521/1](https://community.mp3tag.de/t/521/1)

DD.20121111.2125.CET

---

<div class="post-metadata">

### Author: ![ykeyke](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/y/d26b3c/32.png) [@ykeyke](https://community.mp3tag.de/u/ykeyke)
#### Post date: [November 12, 2012, 9:05pm UTC](https://community.mp3tag.de/t/rare-substitution-in-filename/14102/18 "2012-11-12T21:05:23Z")

</div>

Hi folks,

Well, it's just to thank you both **stevehero** and **DetlevD** for the help, now after studying the present issue with its ramifications, and the references of the links by DetlevD, I feel a little (just a little 😳 ) less confused... But I assume that the regex is a huge world, and hope that with time and kind orientation from you, can get adequate knowledge...

Still to solve, the last issue, that is to convert:

"123-456 A file to change version 123.123 201145-63 (2025-36-87-833) 123-456 A file to change version 123.123 201145-63 (2025-36-87-833).mp3"

into:

"123-456 A file to change version 123.123 201145-63 (-253687833) 123-456 A file to change version 123.123 201145-63 (-253687833).mp3"

using only **regex, anchors and parenthesis.**

I'm on my way to solve it, if I have the chance to get it, I'll post it...

Until then, thank you again for your attention.

Greetings

N.B: Actually, this last substitution isn't the original issue, as this one is already solved, but I modified it to better understand the regex.

---

<div class="post-metadata">

### Author: ![stevehero](https://community.mp3tag.de/user_avatar/community.mp3tag.de/stevehero/32/337_2.png) [@stevehero](https://community.mp3tag.de/u/stevehero)
#### Post date: [November 12, 2012, 10:57pm UTC](https://community.mp3tag.de/t/rare-substitution-in-filename/14102/19 "2012-11-12T22:57:54Z")

</div>

> [@ykeyke](#):
>
> "123-456 A file to change version 123.123 201145-63 (2025-36-87-833) 123-456 A file to change version 123.123 201145-63 (2025-36-87-833).mp3"
> 
> into:
> 
> "123-456 A file to change version 123.123 201145-63 (-253687833) 123-456 A file to change version 123.123 201145-63 (-253687833).mp3"

You don't need to find the 'mp3' at the end seeing as I'm using the **%\_filename%** and not the **%\_filename\_ext%**  
   
Begin Action Group **\_Script Test#TEST**

**Action #1** _Actiontype 5:_ **Format value** _Field \_\_\_\_\_\_:_ **\_FILENAME** _Formatstring:_ **$regexp(%\_filename%,'^([^\(]+\()\d{2}(\d{2})-(\d+)-(\d+)-(\d+\))([^\(]+\()\d{2}(\d{2})-(\d+)-(\d+)-(\d+\)) ,'$1-$2$3$4$5$6-$7$8$9$10')**

End Action Group **\_Script Test#TEST** (1 Action)

**See how regexp works:**

 ![](https://community.mp3tag.de/uploads/default/original/2X/5/53f263924a5af5fab668c4d20be9a99526b9b6c4.jpg)  
  
 

 ![](https://community.mp3tag.de/uploads/default/original/2X/5/53f263924a5af5fab668c4d20be9a99526b9b6c4.jpg)

---

<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: [November 13, 2012, 7:00am UTC](https://community.mp3tag.de/t/rare-substitution-in-filename/14102/20 "2012-11-13T07:00:22Z")

</div>

> [@ykeyke](#):
>
> ... I assume that the regex is a huge world, and hope that with time and kind orientation from you, can get adequate knowledge... Still to solve, the last issue, that is to convert: ... using only **regex, anchors and parenthesis.**

**$regexp(%TEST%,'^(?:(\d{3}-\d{3}\s.+\s)\(\d{2}(\d{2})-(\d{2})-(\d{2})-(\d{3})\)\s\*){2}$','$1(-$2$3$4$5)')** 

**```
                 <!--coloro:#000000--><span style="color:#000000"><!--/coloro--> ~~~~~~~~~~~~~~~~~~~~~~  ~~~~~~~~~~  ~~~~~ <!--colorc--></span><!--/colorc-->
                 <!--coloro:#000000--><span style="color:#000000"><!--/coloro-->$1 <!--colorc--></span><!--/colorc--> <!--coloro:#000000--><span style="color:#000000"><!--/coloro-->$2 <!--colorc--></span><!--/colorc--> <!--coloro:#000000--><span style="color:#000000"><!--/coloro-->$3 <!--colorc--></span><!--/colorc--> <!--coloro:#000000--><span style="color:#000000"><!--/coloro-->$4 <!--colorc--></span><!--/colorc--> <!--coloro:#000000--><span style="color:#000000"><!--/coloro-->$5<!--colorc--></span><!--/colorc--></b><!--fontc--></span><!--/fontc--><!--sizec--></span><!--/sizec-->**

**```**

 **$regexp(%TEST%,'^(?:([^(]+)\(\d{2}(\d{2})-(\d{2})-(\d{2})-(\d{3})\)\s\*){2}$','$1(-$2$3$4$5)')** 

**```
                 <!--coloro:#000000--><span style="color:#000000"><!--/coloro--> ~~~~~~~~~~  ~~~~~~~~~~  ~~~~~ <!--colorc--></span><!--/colorc-->
                 <!--coloro:#000000--><span style="color:#000000"><!--/coloro-->$1 <!--colorc--></span><!--/colorc--> <!--coloro:#000000--><span style="color:#000000"><!--/coloro-->$2 <!--colorc--></span><!--/colorc--> <!--coloro:#000000--><span style="color:#000000"><!--/coloro-->$3 <!--colorc--></span><!--/colorc--> <!--coloro:#000000--><span style="color:#000000"><!--/coloro-->$4 <!--colorc--></span><!--/colorc--> <!--coloro:#000000--><span style="color:#000000"><!--/coloro-->$5<!--colorc--></span><!--/colorc--></b><!--fontc--></span><!--/fontc--><!--sizec--></span><!--/sizec-->**

**```**

 **$regexp(%TEST%,'^(?:([^(]+)\(\d{2}(\d{2})-(\d+)-(\d+)-(\d+)\)\s\*){2}$','$1(-$2$3$4$5)')** 

**```
                 <!--coloro:#000000--><span style="color:#000000"><!--/coloro--> ~~~~~~~~~~  ~~~~~~ ~~~<!--colorc--></span><!--/colorc-->
                 <!--coloro:#000000--><span style="color:#000000"><!--/coloro-->$1 <!--colorc--></span><!--/colorc--> <!--coloro:#000000--><span style="color:#000000"><!--/coloro-->$2 <!--colorc--></span><!--/colorc--> <!--coloro:#000000--><span style="color:#000000"><!--/coloro-->$3 <!--colorc--></span><!--/colorc--> <!--coloro:#000000--><span style="color:#000000"><!--/coloro-->$4 <!--colorc--></span><!--/colorc--> <!--coloro:#000000--><span style="color:#000000"><!--/coloro-->$5<!--colorc--></span><!--/colorc--></b><!--fontc--></span><!--/fontc--><!--sizec--></span><!--/sizec-->**

**```**

 

**From:  
123-456 A file to change version 123.123 201145-63 (2025-36-87-833) 123-456 A file to change version 123.123 201145-63 (2025-36-87-833)  
To:  
123-456 A file to change version 123.123 201145-63 (-253687833)**

 **$regexp(%TEST%,'^(?:(\d{3}-\d{3}\s.+\s)\(\d{2}(\d{2})-(\d{2})-(\d{2})-(\d{3})\)\s\*){2}$','$1(-$2$3$4$5) $1(-$2$3$4$5)') $regexp(%TEST%,'^(?:([^(]+)\(\d{2}(\d{2})-(\d{2})-(\d{2})-(\d{3})\)\s\*){2}$','$1(-$2$3$4$5) $1(-$2$3$4$5)')** 

**From:  
123-456 A file to change version 123.123 201145-63 (2025-36-87-833) 123-456 A file to change version 123.123 201145-63 (2025-36-87-833)  
To:  
123-456 A file to change version 123.123 201145-63 (-253687833) 123-456 A file to change version 123.123 201145-63 (-253687833)**

 

**DD.20121113.0900.CET**

[Next page](https://community.mp3tag.de/t/rare-substitution-in-filename/14102.md?page=2)
