$retest(x,expr)

It would be great to have the following:

$retest(x,expr) returns true if the pattern specified by the regular expression expr matches the string x, else false. The third optional parameter enables ignore case (1) or disables the ignore case setting (0). Please note that you have to escape comma and other special characters in expr.

Meanwhile, if anyone can suggest a workaround better than this:

$neql(x,$replace(x,expr,somereservedstring))

please tell.

Anyone, please?

Hi.
I don't mind trying to help, but I don't really understand what you want, and I can't understand the purporse of your expression.

If what you want is a way to check if something was found by a Regular Expression, or not, in Mp3Tag that is done knowing this:
When the <search_expression> is found in <source_text>, then only the text found is returned, otherwise the whole <source_text> is returned.

Now you need to somewhow compare the <source_text> with the <return_text>.
But it depends on the contents, so I can't give you a general solution to everycase.
However you certainly have an idea of what is possible for both cases, so you can play with that.

Here is a specific example, just to give you an idea of what I mean:
a ) Suppose that your <source_text> always starts with a number with 3 digits, like 123, 894, etc.
b ) Suppose your <return_text> should always start with a text character.

This way you just have to verify if the first chracter of the <return_text> is a digit.
Use function: $isdigit(x) - returns true if character x is a decimal number.

In case it returns true, then you know that your search was NOT_FOUND.
Sometimes, when I import text files, my first character is a special one, precisely because of this, and I call it the NOT_FOUND character. If that character is the first in the <return_text>, then it means that what I was searching was not found. :slight_smile:

I don't know if this is what you're looking after, but maybe it will help.

Yup.

The expression you said you didn't understand does just that.

My request was for "better than this".

Thanks anyway for the suggestion.

Try: If regexp matches, then apply regexp, else do otherwise. $if($eql($regexp('string','expression',,opt_ignorecase),),
<!--coloro:#800080--><span style="color:#800080"><!--/coloro-->$regexp<!--colorc--></span><!--/colorc--><!--coloro:#000000--><span style="color:#000000"><!--/coloro-->(<!--colorc--></span><!--/colorc--><!--coloro:#008080--><span style="color:#008080"><!--/coloro-->'<!--colorc--></span><!--/colorc--><!--coloro:#008080--><span style="color:#008080"><!--/coloro-->string<!--colorc--></span><!--/colorc--><!--coloro:#008080--><span style="color:#008080"><!--/coloro-->'<!--colorc--></span><!--/colorc--><!--coloro:#000000--><span style="color:#000000"><!--/coloro-->,<!--colorc--></span><!--/colorc--><!--coloro:#008080--><span style="color:#008080"><!--/coloro-->'<!--colorc--></span><!--/colorc--><!--coloro:#008080--><span style="color:#008080"><!--/coloro-->expression<!--colorc--></span><!--/colorc--><!--coloro:#008080--><span style="color:#008080"><!--/coloro-->'<!--colorc--></span><!--/colorc--><!--coloro:#000000--><span style="color:#000000"><!--/coloro-->,<!--colorc--></span><!--/colorc--><!--coloro:#008080--><span style="color:#008080"><!--/coloro-->'<!--colorc--></span><!--/colorc--><!--coloro:#008080--><span style="color:#008080"><!--/coloro-->replacement<!--colorc--></span><!--/colorc--><!--coloro:#008080--><span style="color:#008080"><!--/coloro-->'<!--colorc--></span><!--/colorc--><!--coloro:#000000--><span style="color:#000000"><!--/coloro-->,<!--colorc--></span><!--/colorc--><!--coloro:#000000--><span style="color:#000000"><!--/coloro-->opt_ignorecase<!--colorc--></span><!--/colorc--><!--coloro:#000000--><span style="color:#000000"><!--/coloro-->)<!--colorc--></span><!--/colorc--><!--coloro:#000000--><span style="color:#000000"><!--/coloro-->,<!--colorc--></span><!--/colorc--><!--coloro:#008080--><span style="color:#008080"><!--/coloro-->'<!--colorc--></span><!--/colorc--><!--coloro:#008080--><span style="color:#008080"><!--/coloro-->otherwise<!--colorc--></span><!--/colorc--><!--coloro:#008080--><span style="color:#008080"><!--/coloro-->'<!--colorc--></span><!--/colorc--><!--coloro:#000000--><span style="color:#000000"><!--/coloro-->)<!--colorc--></span><!--/colorc-->
$if($neql($regexp('string','expression',,opt_ignorecase),),'otherwise',
<!--coloro:#800080--><span style="color:#800080"><!--/coloro-->$regexp<!--colorc--></span><!--/colorc--><!--coloro:#000000--><span style="color:#000000"><!--/coloro-->(<!--colorc--></span><!--/colorc--><!--coloro:#008080--><span style="color:#008080"><!--/coloro-->'<!--colorc--></span><!--/colorc--><!--coloro:#008080--><span style="color:#008080"><!--/coloro-->string<!--colorc--></span><!--/colorc--><!--coloro:#008080--><span style="color:#008080"><!--/coloro-->'<!--colorc--></span><!--/colorc--><!--coloro:#000000--><span style="color:#000000"><!--/coloro-->,<!--colorc--></span><!--/colorc--><!--coloro:#008080--><span style="color:#008080"><!--/coloro-->'<!--colorc--></span><!--/colorc--><!--coloro:#008080--><span style="color:#008080"><!--/coloro-->expression<!--colorc--></span><!--/colorc--><!--coloro:#008080--><span style="color:#008080"><!--/coloro-->'<!--colorc--></span><!--/colorc--><!--coloro:#000000--><span style="color:#000000"><!--/coloro-->,<!--colorc--></span><!--/colorc--><!--coloro:#008080--><span style="color:#008080"><!--/coloro-->'<!--colorc--></span><!--/colorc--><!--coloro:#008080--><span style="color:#008080"><!--/coloro-->replacement<!--colorc--></span><!--/colorc--><!--coloro:#008080--><span style="color:#008080"><!--/coloro-->'<!--colorc--></span><!--/colorc--><!--coloro:#000000--><span style="color:#000000"><!--/coloro-->,<!--colorc--></span><!--/colorc--><!--coloro:#000000--><span style="color:#000000"><!--/coloro-->opt_ignorecase<!--colorc--></span><!--/colorc--><!--coloro:#000000--><span style="color:#000000"><!--/coloro-->)<!--colorc--></span><!--/colorc--><!--coloro:#000000--><span style="color:#000000"><!--/coloro-->)<!--colorc--></span><!--/colorc--></b><!--fontc--></span><!--/fontc--><!--sizec--></span><!--/sizec-->

DD.20150309.1325.CET

Thanks D. I assume you're suggesting:

$eql($regexp(x,expr,),)

is better than the existing workaround:

$neql(x,$replace(x,expr,somereservedstring))

but it doesn't look better to me. It fails when x is an empty string.

Yes, because the regex has been evaluated and matched and has delivered the wanted result, which is the empty string, any detour with a 'reserved string' is not necessary.
If there is no match, then the Mp3tag $regexp function returns the full unchanged input string, which leads to the else-case of 'otherwise'.

Huh?

$if($eql($regexp(,'^.+$',,1),),$regexp(,'^.+$','replacement',1),'otherwise') ==> emptystring

... this looks ok, it delivers an empty string.

Empty input, empty output.
It makes no sense to find any match in an empty string.
This case can be catched before invoking the regexp.

$if(%ARTIST%,$if($eql($regexp(%ARTIST%,'^.+$',,1),),$regexp(%ARTIST%,'^.+$','replacement',1),'otherwise'),'inputstring does not exist')

DD.20150309.1714.CET

That particular case hides the failure.

This case shows it:

$if($eql($regexp(,^a$,),),y,n) -> y

It makes sense to test an empty string and it make sense to test a string for emptyness.

Where is the "failure"?
The result is correct ...

$if($eql($regexp(,'oqreß09´fff fg309dfkfqq5',),),'y','n') -> 'y'

Yes, the function $regexp returns for a given empty input string an empty output string, ...
regardless of the regexp does match or does not match, ...
empty input == empty output
... but this result has nothing to do with the applied regular expression condition.

The addition knows a similar effect: a + 0 ==> a
The multiplication knows a similar effect: a * 1 ==> a

$if($eql($regexp('a','^a$',),),$regexp('a','^a$','x'),'n') ==> 'x' ... it has matched and the rule has been applicated, ok. $if($eql($regexp('b','^a$',),),$regexp('b','^a$','x'),'n') ==> 'n' ... it has not matched $if($eql($regexp(,'^a$',),),$regexp(,'^a$','x'),'n') ==> empty output string, is same as input string ... there is no knowledge about matching yes or no.

This is sort of tri-state logic, having a third case 'cannot say'.

DD.20150309.1925.CET

The result

$if($eql($regexp(,^a$,),),y,n) -> y

fails to meet the stated requirement:

"[the condition expression]returns true if the pattern specified by the regular expression expr matches the string x, else false. "

The pattern does not meet match the string, yet the expression returns true rather than false as required.