# $num within $Regexp has unexpected behaviour

**URL:** <https://community.mp3tag.de/t/num-within-regexp-has-unexpected-behaviour/15780>\
**Category:** Support\
**Created:** [June 2, 2014, 12:42pm UTC](https://community.mp3tag.de/t/num-within-regexp-has-unexpected-behaviour/15780 "2014-06-02T12:42:05Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![dcassidy](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/d/a88e57/32.png) [@dcassidy](https://community.mp3tag.de/u/dcassidy)\
**Post date:** [June 2, 2014, 12:42pm UTC](https://community.mp3tag.de/t/num-within-regexp-has-unexpected-behaviour/15780/1 "2014-06-02T12:42:05Z")

</div>

Quite a simple scenario...

$regexp('This is Track 16 from the album','^(?:._)(?\d{2})(._?)$',$+{Track})

> > Returns **16**

$num($regexp('This is Track 16 from the album','^(?:._)(?\d{2})(._?)$',$+{Track}),3)

> > Returns **016**

However,

$regexp('This is Track 16 from the album','^(?:._)(?\d{2})(._?)$',$num($+{Track},3))

> > Returns **000**

Is there a conversion of the contained group (i.e. that must be performed  
BEFORE $num (Pad decimal number with leading zeros) function is executed ?

Tried a few things (using $kleft, $trim) but to no avail ??  
General question: What are the limitations of functions within $Regexp

Cheers,

Desmond.

---

<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 2, 2014, 3:19pm UTC](https://community.mp3tag.de/t/num-within-regexp-has-unexpected-behaviour/15780/2 "2014-06-02T15:19:36Z")

</div>

This works ...

 **$regexp('This is Track 16 from the album','^.\*Track (\d{2}).\*$','$1') \>\> Returns 16 $num($regexp('This is Track 16 from the album','^.\*Track (\d{2}).\*$','$1'),3) \>\> Returns 016**

> [@Dezzz](#):
>
> ... General question: What are the limitations of functions within $Regexp ...

The Mp3tag regexp implementation makes use of the "boost.regex" machine.  
[http://www.boost.org/doc/libs/1\_55\_0/libs/...gex/syntax.html](http://www.boost.org/doc/libs/1_55_0/libs/regex/doc/html/boost_regex/syntax.html)

When using the Mp3tag function $regexp() there seems to be no way to use Mp3tag scripting functions in the replacement part.  
When using the action "Replace using Regular Expression" there is allowed to use other Mp3tag scripting functions in the replacement part, but I do not know whether this is valid for all Mptag scripting functions, however $num() should work.

When using the Mp3tag function $regexp() it is possible to assemble the expression part from constant text and function output, however this works ...

**$regexp('This is Track 16 from the album', '^(?:.\*)(?\<'$upper('Track')'\>\d{2})(.\*?)$','$+{TRACK}') \>\> Returns 16 $regexp('This is Track 16 from the album', '^(?:.\*)(?\<'$regexp('Track','.\*','\U$0')'\>\d{2})(.\*?)$','$+{TRACK}') \>\> Returns 16**

DD.20140602.2016.CEST

---

<div class="post-metadata">

**Author:** ![dcassidy](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/d/a88e57/32.png) [@dcassidy](https://community.mp3tag.de/u/dcassidy)\
**Post date:** [June 19, 2014, 12:57pm UTC](https://community.mp3tag.de/t/num-within-regexp-has-unexpected-behaviour/15780/3 "2014-06-19T12:57:56Z")

</div>

Many thanks for the clarification...

---

<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/num-within-regexp-has-unexpected-behaviour/15780/4 "2026-02-09T12:25:05Z")

</div>

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


