Validate Against Multi-Value Fields

Suppose I have one or more default composers. Is there a nice clean regex to compare a new incoming composer against the defaults?

$if($eql(%newcomposer%,%meta(%defaultcomposers,all),yes,no)?

I can obviously parse and search between \\, but I'm hoping for a solution that is more elegant.

Thx
K

A regular expression is not needed, it can be solved using standard functions.

  1. Convert the content from the multi-value tag-field COMPOSERS into a string:
    $meta_sep(COMPOSERS,$char(9))$char(9)

  2. Search the new composer within the string of composers:
    $strstr($meta_sep(COMPOSERS,$char(9))$char(9),%COMPOSER%$char(9))

  3. If the result from step 2 is zero, then the composer does not exist in the list of composers, otherwise the composer does exist already.
    $ifgreater($strstr($meta_sep(COMPOSERS,$char(9))$char(9),%COMPOSER%$char(9)),0,'yes','no')

This is a case sensitive proposal.
You can make it case insensitive by using function $lower or $upper.

DD.20160708.1004.CEST

Your approach is similar in concept to the one I am using, which makes the larger expression within which it is embedded look quite messy and difficult to interpret.

I'm not familiar with the meta concept and was hoping there was some secret magic equation, function or incantation that would accomplish the desired task with fewer leaps of programming logic.

And of course both your approach and my similar regexp approach gives false positives when the comparison is a substring of an existing composer (e.g., it considers composer=university valid when one of the default composers is university of south africa).

Thanks.

K

Here's one that's a little bit shorter.

$if($eql($regexp(%composer%,(?:$meta_sep(defaultcomposer,|)),),),yes,no)

My first approach tries to reduce the false match of substrings, but it was not perfect yet, because each COMPOSER value needs a left and a right delimiter to give a distinctive value to compare.
As the delimiter character I proposed the $char(9), because it nearly never exists in a COMPOSER value, but you are free to apply some other seldom used character as a delimiter.

This filterstring works for me:
"$strstr('|'$meta_sep(COMPOSERS,'|')'|','|'%COMPOSER%'|')" GREATER 0

... or equivalent as a formatstring ...
$ifgreater($strstr('|'$meta_sep(COMPOSERS,'|')'|','|'%COMPOSER%'|'),0,'yes','no')

DD.20160709.1143.CEST

Thx