# $if($regexpmatch(a,b,c),x,y)

**URL:** https://community.mp3tag.de/t/if-regexpmatch-a-b-c-x-y/11981
**Category:** Support
**Created:** [May 6, 2011, 5:09pm UTC](https://community.mp3tag.de/t/if-regexpmatch-a-b-c-x-y/11981 "2011-05-06T17:09:09Z")
**Posts on this page:** 15
**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: [May 6, 2011, 5:09pm UTC](https://community.mp3tag.de/t/if-regexpmatch-a-b-c-x-y/11981/1 "2011-05-06T17:09:09Z")

</div>

What's the best coding for a $regexpmatch returning bool? My best uses $regexp and a reserved string - yuk!

---

<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: [May 7, 2011, 12:23am UTC](https://community.mp3tag.de/t/if-regexpmatch-a-b-c-x-y/11981/2 "2011-05-07T00:23:35Z")

</div>

Please explain ... _if($regexpmatch(a,b,c),x,y)_  
What meaning has _a, b, c, x, y_?

Be aware of the fact, that the Mp3tag Scripting Languages currently actually never return any boolean value to the user. Any handling of boolean result is going on internally behind the scene.  
I would say it is a design error of the scripting language per se.

DD.20110507.0433.CEST

---

<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: [May 7, 2011, 1:06am UTC](https://community.mp3tag.de/t/if-regexpmatch-a-b-c-x-y/11981/3 "2011-05-07T01:06:41Z")

</div>

> [@DetlevD](#):
>
> Please explain ... _if($regexpmatch(a,b,c),x,y)_  
> What meaning has _a, b, c, x, y_?

Same as for $regexp and $if .

---

<div class="post-metadata">

### Author: ![JJ\_Johnson](https://community.mp3tag.de/user_avatar/community.mp3tag.de/jj_johnson/32/67_2.png) [@JJ\_Johnson](https://community.mp3tag.de/u/JJ_Johnson)
#### Post date: [May 7, 2011, 1:09am UTC](https://community.mp3tag.de/t/if-regexpmatch-a-b-c-x-y/11981/4 "2011-05-07T01:09:14Z")

</div>

I would assume he means he wishes only to determine if there's a regex match in string _a_, and not to use the replacement functionality of $regexp(). So, if there's a regex match in string _a_ then _x_, else _y_. I'm not sure what _c_ would be used for, but I'm guessing it would not be used.

I haven't played with it, but I wonder if $regexp() returns True or False depending on whether or not a match was made. If so, then it could easily be used within an $if() function. You could avoid altering _a_ by replacing the matched text with itself.

---

<div class="post-metadata">

### Author: ![JJ\_Johnson](https://community.mp3tag.de/user_avatar/community.mp3tag.de/jj_johnson/32/67_2.png) [@JJ\_Johnson](https://community.mp3tag.de/u/JJ_Johnson)
#### Post date: [May 7, 2011, 3:30am UTC](https://community.mp3tag.de/t/if-regexpmatch-a-b-c-x-y/11981/5 "2011-05-07T03:30:37Z")

</div>

> [@JJ Johnson](#):
>
> I haven't played with it, but I wonder if $regexp() returns True or False depending on whether or not a match was made.

Well, I've played with it now and it does not. It always returns the altered or unaltered string, which always evaluates as FALSE.

---

<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: [May 7, 2011, 3:42am UTC](https://community.mp3tag.de/t/if-regexpmatch-a-b-c-x-y/11981/6 "2011-05-07T03:42:47Z")

</div>

> [@chrisjj](#):
>
> Same as for $regexp and $if .

This makes no sense, because testing for a match needs no replacing.

DD.20110507.0747.CEST

---

<div class="post-metadata">

### Author: ![JJ\_Johnson](https://community.mp3tag.de/user_avatar/community.mp3tag.de/jj_johnson/32/67_2.png) [@JJ\_Johnson](https://community.mp3tag.de/u/JJ_Johnson)
#### Post date: [May 7, 2011, 3:51am UTC](https://community.mp3tag.de/t/if-regexpmatch-a-b-c-x-y/11981/7 "2011-05-07T03:51:52Z")

</div>

> [@DetlevD](#):
>
> This makes no sense, because testing for a match needs no replacing.

How do you test for a regex match in Mp3tag without also replacing? I don't see any other regex functions in the documentation. Nothing among the boolean functions.

---

<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: [May 7, 2011, 4:34am UTC](https://community.mp3tag.de/t/if-regexpmatch-a-b-c-x-y/11981/8 "2011-05-07T04:34:31Z")

</div>

> [@JJ Johnson](#):
>
> How do you test for a regex match in Mp3tag without also replacing? I don't see any other regex functions in the documentation. Nothing among the boolean functions.

Going out from chrisjj's opening post I assumed, that he has proposed a new functionality for the Mp3tag Scripting Language, so maybe I have misunderstood his request.

Currently the function $regexp on no match returns the unchanged input string (the replacing will not really happen).  
This failure case can be tested by the function $eql respectively by the function $neql (is the regexp result the same as the input or not?).  
To make a decision what to do next, you can use the function $if.

DD.20110507.0838.CEST

---

<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: [May 7, 2011, 8:22am UTC](https://community.mp3tag.de/t/if-regexpmatch-a-b-c-x-y/11981/9 "2011-05-07T08:22:00Z")

</div>

> a match needs no replacing.

Good point. How about:

$if($regexpmatch(a,B),x,y)

> I assumed, that you have proposed a new functionality

No. I'm simply asking "What's the best coding for a $regexpmatch returning bool?"

If I could see the best coding for $if($regexpmatch(a,B),x,y), that would answer my question. Thanks.

---

<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: [May 7, 2011, 9:29am UTC](https://community.mp3tag.de/t/if-regexpmatch-a-b-c-x-y/11981/10 "2011-05-07T09:29:09Z")

</div>

> [@chrisjj](#):
>
> ... If I could see the best coding ...

As layed out in post #8 ... with the currently given set of scripting functions ... someone can code as following.

**$if($eql('Any Text',$regexp('Any Text','^Text',)),'Match No','Match Yes')**

==\> 'Match No'

**$if($eql('Any Text',$regexp('Any Text','Text$',)),'Match No','Match Yes')**

==\> 'Match Yes'

The test string 'Any Text' can be replaced by any tag-field content, for example %TITLE%.

DD.20110507.1333.CEST

---

<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: [May 7, 2011, 10:40am UTC](https://community.mp3tag.de/t/if-regexpmatch-a-b-c-x-y/11981/11 "2011-05-07T10:40:26Z")

</div>

Thanks D. I have noted:

$if($ **n** eql(subject,$regexp(subject,pattern,)),whenmatched,whennotmatched)

for the more consistent parameter ordering.

If you can think of an improvement that avoids repeating "subject", please say!

---

<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: [May 22, 2011, 4:57pm UTC](https://community.mp3tag.de/t/if-regexpmatch-a-b-c-x-y/11981/12 "2011-05-22T16:57:08Z")

</div>

> [@chrisjj](#):
>
> If you can think of an improvement that avoids repeating "subject", please say!

I have long subjects that is making it quite desirable to avoid this repeating of subject. Any solution?

---

<div class="post-metadata">

### Author: ![JJ\_Johnson](https://community.mp3tag.de/user_avatar/community.mp3tag.de/jj_johnson/32/67_2.png) [@JJ\_Johnson](https://community.mp3tag.de/u/JJ_Johnson)
#### Post date: [May 22, 2011, 6:07pm UTC](https://community.mp3tag.de/t/if-regexpmatch-a-b-c-x-y/11981/13 "2011-05-22T18:07:44Z")

</div>

> [@chrisjj](#):
>
> I have long subjects that is making it quite desirable to avoid this repeating of subject. Any solution?

Copy it to a temporary field. Run your action containing the regex expression, then remove the temp field.

---

<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: [May 22, 2011, 6:12pm UTC](https://community.mp3tag.de/t/if-regexpmatch-a-b-c-x-y/11981/14 "2011-05-22T18:12:48Z")

</div>

> [@JJ Johnson](#):
>
> Copy it to a temporary field. Run your action containing the regex expression, then remove the temp field.

Thanks, but doesn't work in Export configs.

---

<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:23pm UTC](https://community.mp3tag.de/t/if-regexpmatch-a-b-c-x-y/11981/15 "2026-02-09T12:23:05Z")

</div>


