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

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.


Same as for $regexp and $if .

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.

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

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.

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.


a match needs no replacing.

Good point. How about:


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.

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%.


Thanks D. I have noted:


for the more consistent parameter ordering.

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?

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.