# \[X\] Regexp range repeat is broken

**URL:** https://community.mp3tag.de/t/x-regexp-range-repeat-is-broken/6381
**Category:** No Bugs
**Created:** [March 4, 2008, 12:41pm UTC](https://community.mp3tag.de/t/x-regexp-range-repeat-is-broken/6381 "2008-03-04T12:41:32Z")
**Posts on this page:** 14
**Page:** 1

<div class="post-metadata">

### Author: ![chrisjj](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/c/a698b9/32.png) [@chrisjj](https://community.mp3tag.de/u/chrisjj)
#### Post date: [March 4, 2008, 12:41pm UTC](https://community.mp3tag.de/t/x-regexp-range-repeat-is-broken/6381/1 "2008-03-04T12:41:32Z")

</div>

In e.g. Convert | Tag - Filename

$regexp(aaa,a{2,4},X)

says

REGEXP ERROR: Regular expressionUnmatched { or{.wma

(sic) even though there is no unmatched { or {.

$regexp(aaa,a{2},X) works fine.

---

<div class="post-metadata">

### Author: ![dano](https://community.mp3tag.de/user_avatar/community.mp3tag.de/dano/32/6_2.png) [@dano](https://community.mp3tag.de/u/dano)
#### Post date: [March 4, 2008, 1:34pm UTC](https://community.mp3tag.de/t/x-regexp-range-repeat-is-broken/6381/2 "2008-03-04T13:34:04Z")

</div>

comma breaks the syntax, it must be escaped  
$regexp(aaa,'a{2,4}',X)

---

<div class="post-metadata">

### Author: ![chrisjj](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/c/a698b9/32.png) [@chrisjj](https://community.mp3tag.de/u/chrisjj)
#### Post date: [March 4, 2008, 2:04pm UTC](https://community.mp3tag.de/t/x-regexp-range-repeat-is-broken/6381/3 "2008-03-04T14:04:00Z")

</div>

> it must be escaped

Oops! Thanks Dano.

Another addition needed to the list of reserved characters at help\main\_scripting.html .

> $regexp(aaa,'a{2,4}',X)

Actually I think that style is not in general safe, since it can break quoting already in the string. Safer is $regexp(aaa,a{2','4},X).

Also I find $regexp(aaa,(a{2,4}),X) is a workaround, possibly unintended!

---

<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: [March 4, 2008, 6:07pm UTC](https://community.mp3tag.de/t/x-regexp-range-repeat-is-broken/6381/4 "2008-03-04T18:07:12Z")

</div>

> [@chrisjj](#):
>
> ... \> $regexp(aaa,'a{2,4}',X) ...

I recently found out ([RegExpr für klassiche Beschriftung von Tonart](https://community.mp3tag.de/t/6319/4)) that the Mp3tag function **$regexp(p1,p2,p3)** expects as second parameter a literal string which contains the regular expression formular. Enclosing this literal string with single quotation characters allows the user to use any literal character in the regular expression, even those characters which needs compulsory to be escaped at other scripting places within Mp3tag.

I think it would become more clearly and handy if a user can read it from the documentation that parameter p2 of the Mp3tag scripting function **$regexp(p1,p2,p3)** should always be treated as a literal string which needs to be enclosed with single quotation marks.

By the way, round brackets should not to be allowed working as a string delimiter within function parameter list.

DD.20080304.2007.CET

---

<div class="post-metadata">

### Author: ![chrisjj](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/c/a698b9/32.png) [@chrisjj](https://community.mp3tag.de/u/chrisjj)
#### Post date: [March 4, 2008, 7:34pm UTC](https://community.mp3tag.de/t/x-regexp-range-repeat-is-broken/6381/5 "2008-03-04T19:34:22Z")

</div>

> Enclosing this literal string with single quotation characters allows the user to use any  
> literal character in the regular expression, even those characters which needs  
> compulsory to be escaped at other scripting places within Mp3tag.

The exception being the quote character itself, mind! 😉

> round brackets should not to be allowed working as a string delimiter within function  
> parameter list.

It only appeared to, because the pattern parser took precedence over the function list parser. The proof is

$regexp(aaa,(a{2,4}),X$1Y) -\> XaaaY

Given the docs, it's a bug.

---

<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: [March 4, 2008, 8:05pm UTC](https://community.mp3tag.de/t/x-regexp-range-repeat-is-broken/6381/6 "2008-03-04T20:05:22Z")

</div>

> [@chrisjj](#):
>
> ... The exception being the quote character itself, mind! 😉 ...

Hmm, yes, but from the sight within the regular expression the single quote character has to be escaped as **'** , or is this impossible, yet I didn't verify this situation?

DD.20080304.2203.CET

I played around a bit, now, I'm totally confused.

$regexp('a''aa','a',XY) gives **XYXYXY**

$regexp(a''aa,'a',XY) gives **XY'XYXY**

$regexp('a''aa','a''',XY) gives **aaa**

$regexp('a''aa','a'',XY) gives **[SYNTAX ERROR IN FORMATTING STRING]**

DD.20080304.2226.CET

---

<div class="post-metadata">

### Author: ![chrisjj](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/c/a698b9/32.png) [@chrisjj](https://community.mp3tag.de/u/chrisjj)
#### Post date: [March 4, 2008, 8:58pm UTC](https://community.mp3tag.de/t/x-regexp-range-repeat-is-broken/6381/7 "2008-03-04T20:58:25Z")

</div>

> the single quote character has to be escaped as **'** ,  
> or is this impossible, yet I didn't verify this situation?

No, it has to be escape by a quote i.e. to get one literal ' , you write '' .

> I played around a bit, now, I'm totally confused.  
> $regexp('a''aa','a',XY) gives **XYXYXY**

A' went missing! I'm baffeld.

> $regexp(a''aa,'a',XY) gives **XY'XYXY**

Figures.

> $regexp('a''aa','a''',XY) gives **aaa**

Baffeld!

> $regexp('a''aa','a'',XY) gives **[SYNTAX ERROR IN FORMATTING STRING]**

Figures.

By the way, Convert | Tag - Filename preview is a great way to try these fast.

DD.20080304.2226.CET  
[/quote]

---

<div class="post-metadata">

### Author: ![dano](https://community.mp3tag.de/user_avatar/community.mp3tag.de/dano/32/6_2.png) [@dano](https://community.mp3tag.de/u/dano)
#### Post date: [March 4, 2008, 9:10pm UTC](https://community.mp3tag.de/t/x-regexp-range-repeat-is-broken/6381/8 "2008-03-04T21:10:20Z")

</div>

'a''aa' is the same as aaa  
if you want a'aa you must write 'a''''aa'

---

<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: [March 5, 2008, 6:24pm UTC](https://community.mp3tag.de/t/x-regexp-range-repeat-is-broken/6381/9 "2008-03-05T18:24:11Z")

</div>

I'm still unsure about escaping ...  
**$regexp('a''''aa','a''',x)** which results in **xaa**.

DD.20080305.2024.CET

---

<div class="post-metadata">

### Author: ![dano](https://community.mp3tag.de/user_avatar/community.mp3tag.de/dano/32/6_2.png) [@dano](https://community.mp3tag.de/u/dano)
#### Post date: [March 5, 2008, 9:10pm UTC](https://community.mp3tag.de/t/x-regexp-range-repeat-is-broken/6381/10 "2008-03-05T21:10:22Z")

</div>

There seems to be nothing wrong with this example.  
Same as $regexp(baa,b,x) --\> xaa

---

<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: [March 6, 2008, 4:03am UTC](https://community.mp3tag.de/t/x-regexp-range-repeat-is-broken/6381/11 "2008-03-06T04:03:54Z")

</div>

> [@dano](#):
>
> There seems to be nothing wrong with this example. Same as $regexp(baa,b,x) --\> xaa

... but ... analog to the **b** in your sample above ... **a''''** is not the same as **a''** , obviously.

DD.20080306.0603.CET

---

<div class="post-metadata">

### Author: ![dano](https://community.mp3tag.de/user_avatar/community.mp3tag.de/dano/32/6_2.png) [@dano](https://community.mp3tag.de/u/dano)
#### Post date: [March 6, 2008, 9:02am UTC](https://community.mp3tag.de/t/x-regexp-range-repeat-is-broken/6381/12 "2008-03-06T09:02:26Z")

</div>

The escape function of the ' ends with the next ' (not like in e.g. delphi where the first and the last ' are connected.  
So 'a''''aa'  
is 'a' + '' + 'aa' whichis a + ' + aa

---

<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: [March 17, 2008, 7:13am UTC](https://community.mp3tag.de/t/x-regexp-range-repeat-is-broken/6381/13 "2008-03-17T07:13:45Z")

</div>

> [@dano](#):
>
> ... So 'a''''aa'  
> is 'a' + '' + 'aa' whichis a + ' + aa

So escaping in Mp3tag goes just the serial way from left to right, there is no 'recursively tree related view' to a string object.  
This explains why a pure '' on a line displays not an empty string, but one '.  
Thank you, Dano, to make this clear.  
Is it true, that Mp3tag scripting language has no syntactical construct to represent an empty string?

DD.20080317.0914.CET

---

<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:22pm UTC](https://community.mp3tag.de/t/x-regexp-range-repeat-is-broken/6381/14 "2018-12-28T14:22:35Z")

</div>

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