# Scope of $regexp Variables

**URL:** <https://community.mp3tag.de/t/scope-of-regexp-variables/17852>\
**Category:** Support\
**Created:** [April 16, 2016, 11:40am UTC](https://community.mp3tag.de/t/scope-of-regexp-variables/17852 "2016-04-16T11:40:48Z")\
**Posts on this page:** 8\
**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:** [April 16, 2016, 11:40am UTC](https://community.mp3tag.de/t/scope-of-regexp-variables/17852/1 "2016-04-16T11:40:48Z")

</div>

For the life of me I cannot find out how to utilize (if at all) regexp variables beyond the expression  
in the overall expression...i.e. extended scope ??

OK..what I am doing is"Format value" of a $regexp expression to a TEMP tag...  
then I USE this TEMP in a 2nd action point.

e.g. in the %title% tag is a date which I wish to save to %RELEASETIME% BUT ONLY if I CAN find it !!

SO Action Point 1 Format Value to TEMP  
$regexp(%title%,'^(?._)(?\d{4}-\d{2}-\d{2})(?._$)',$+{MyDate})

and pulling from TEMP in the next Action to RELEASETIME  
$IF($EQL(%Title%,%TEMP%),,%TEMP%)

CAN I somehow merge these two into 1 statement easily..i.e. DIRECT to RELEASETIME.

I use variables PreText, PostText and MyDate as I REPEAT this structure in other extracts.

Dezzz.

---

<div class="post-metadata">

**Author:** ![ohrenkino](https://community.mp3tag.de/user_avatar/community.mp3tag.de/ohrenkino/32/4843_2.png) [@ohrenkino](https://community.mp3tag.de/u/ohrenkino)\
**Post date:** [April 16, 2016, 11:53am UTC](https://community.mp3tag.de/t/scope-of-regexp-variables/17852/2 "2016-04-16T11:53:23Z")

</div>

If you use the same data (contents) in various contexts, you could create actions first that set this data to user-defined fields (a sort of variable declaration).  
You then re-assemble the other data from these declaration fields.

---

<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:** [April 16, 2016, 12:40pm UTC](https://community.mp3tag.de/t/scope-of-regexp-variables/17852/3 "2016-04-16T12:40:52Z")

</div>

Many thanks for your reply...perhaps an example might help 😉

The whole point of the question was to INQUIRE on the possibility of using VARIABLES WITHIN ONE statement ??

---

<div class="post-metadata">

**Author:** ![ohrenkino](https://community.mp3tag.de/user_avatar/community.mp3tag.de/ohrenkino/32/4843_2.png) [@ohrenkino](https://community.mp3tag.de/u/ohrenkino)\
**Post date:** [April 16, 2016, 1:25pm UTC](https://community.mp3tag.de/t/scope-of-regexp-variables/17852/4 "2016-04-16T13:25:13Z")

</div>

> [@Dezzz](#):
>
> ...The whole point of the question was to INQUIRE on the possibility of using VARIABLES WITHIN ONE statement ??

I doubt that. Any variable only lives within the current function.

Example: you have your string  
Create an action that fills the user-defined tag-fields PRETEXT, POSTTEXT, MYDATE  
(e.g. "Guess values" or whatever. Depends)  
Then use the tag-fields as you need them  
Finally, delete them, when you don't need them anymore.

---

<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:** [April 16, 2016, 1:44pm UTC](https://community.mp3tag.de/t/scope-of-regexp-variables/17852/5 "2016-04-16T13:44:33Z")

</div>

> [@ohrenkino](#):
>
> I doubt that. Any variable only lives within the current function.
> 
> Example: you have your string  
> Create an action that fills the user-defined tag-fields PRETEXT, POSTTEXT, MYDATE  
> (e.g. "Guess values" or whatever. Depends)  
> Then use the tag-fields as you need them  
> Finally, delete them, when you don't need them anymore.

Yes...OK..that's what I was doing anyway with TEMP...

I had a further look and there 'could' be an alternative though haven't seen any examples in here and that is to use conditionals within the regex statement..

Basically if I DO find a date then load that date into MyDate otherwise load a null string into MyDate...

Now I have seen that the syntax is something like (?(A)X|Y)...

But to be quite honest I haven't a clue how I could use this syntax...

---

<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:** [April 16, 2016, 5:25pm UTC](https://community.mp3tag.de/t/scope-of-regexp-variables/17852/6 "2016-04-16T17:25:56Z")

</div>

> [@Dezzz](#):
>
> ... what I am doing is "Format value" of a $regexp expression to a TEMP tag ... then I USE this TEMP in a 2nd action point. ... CAN I somehow merge these two into 1 statement easily..i.e. DIRECT to RELEASETIME. ...

**TEMP \<== $regexp(%TITLE%,'.\*(\d\d\d\d-\d\d-\d\d).\*','$1') RELEASETIME \<== $if($eql(%TITLE%,$regexp(%TITLE%,'.\*(\d\d\d\d-\d\d-\d\d).\*','$1')),,$regexp(%TITLE%,'.\*(\d\d\d\d-\d\d-\d\d).\*','$1'))**

If the function $regexp() does not match, then the function returns the unchanged input string.

DD.20160416.2125.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:** [April 17, 2016, 10:16am UTC](https://community.mp3tag.de/t/scope-of-regexp-variables/17852/7 "2016-04-17T10:16:32Z")

</div>

> [@DetlevD](#):
>
> **TEMP \<== $regexp(%TITLE%,'.\*(\d\d\d\d-\d\d-\d\d).\*','$1') RELEASETIME \<== $if($eql(%TITLE%,$regexp(%TITLE%,'.\*(\d\d\d\d-\d\d-\d\d).\*','$1')),,$regexp(%TITLE%,'.\*(\d\d\d\d-\d\d-\d\d).\*','$1'))**
> 
> If the function $regexp() does not match, then the function returns the unchanged input string.
> 
> DD.20160416.2125.CEST

Yeah...thanks...I think the conditional test with 2 regexp statements has some angles...

---

<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:26pm UTC](https://community.mp3tag.de/t/scope-of-regexp-variables/17852/8 "2026-02-09T12:26:12Z")

</div>

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


