# \[X\] Backreference evaluation inside replacement string

**URL:** https://community.mp3tag.de/t/x-backreference-evaluation-inside-replacement-string/12111
**Category:** No Bugs
**Created:** [June 7, 2011, 3:15pm UTC](https://community.mp3tag.de/t/x-backreference-evaluation-inside-replacement-string/12111 "2011-06-07T15:15:07Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![ptrk.mj](https://community.mp3tag.de/user_avatar/community.mp3tag.de/ptrk.mj/32/300_2.png) [@ptrk.mj](https://community.mp3tag.de/u/ptrk.mj)
#### Post date: [June 7, 2011, 3:15pm UTC](https://community.mp3tag.de/t/x-backreference-evaluation-inside-replacement-string/12111/1 "2011-06-07T15:15:07Z")

</div>

When using regular expression inside title-formatting script (with $regexp() function) backreferences inside replacement string are evaluated after all scripting functions included in replacement are applied.

It makes performing replacements based on a content of backreferences impossible.

This doesn't apply to "Replace with regular expression" action! Action works as it's supposed to: first bacreferences are evaluated, then any existing scripting functions are applied.

Consider regular expression:

Input string: string  
Regular expression: .+  
Replacement: $if($eql($&,string),x,y)

Action applied to a field having "string" as content returns x while..

```
$regexp(string,string,$if($eql($&,string),x,y))

```

..returns y

---

<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 7, 2011, 3:49pm UTC](https://community.mp3tag.de/t/x-backreference-evaluation-inside-replacement-string/12111/2 "2011-06-07T15:49:12Z")

</div>

> [@ptrk.mj](#):
>
> ... Consider regular expression:  
> Input string: string  
> Regular expression: .+  
> Replacement: $if($eql($&,string),x,y)

As fas as I know, nearly all of the Mp3tag scripting functions are not allowed to be used in the replacement part of the function $regexp.  
Therefore your example is not a valid expression.

DD.20110607.1950.CEST

---

<div class="post-metadata">

### Author: ![ptrk.mj](https://community.mp3tag.de/user_avatar/community.mp3tag.de/ptrk.mj/32/300_2.png) [@ptrk.mj](https://community.mp3tag.de/u/ptrk.mj)
#### Post date: [June 7, 2011, 5:47pm UTC](https://community.mp3tag.de/t/x-backreference-evaluation-inside-replacement-string/12111/3 "2011-06-07T17:47:19Z")

</div>

> [@DetlevD](#):
>
> As fas as I know, nearly all of the Mp3tag scripting functions are not allowed to be used in the replacement part of the function $regexp.

What do you mean by "not allowed to"? They work! And I use them extensively.

---

<div class="post-metadata">

### Author: ![Florian](https://community.mp3tag.de/user_avatar/community.mp3tag.de/florian/32/5759_2.png) [@Florian](https://community.mp3tag.de/u/Florian)
#### Post date: [December 28, 2018, 2:30pm UTC](https://community.mp3tag.de/t/x-backreference-evaluation-inside-replacement-string/12111/4 "2018-12-28T14:30:28Z")

</div>

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