Any way to shorten $in command with multiple search strings?

Hi,

I’m being picky and would like to make things cleaner, so I’m curious if there is a way to shorten the below?

$if($or($in(%genre%,a),$in(%genre%,b),$in(%genre%,c),$in(%genre%,d)),do something)

Sorry, it probably has been asked many times, but since ‘in’ is a short string that does not return meaningful search engine results.

The method that comes to mind for me…

Use $rsearch() and put a word boundary indicator (\b) before and after the search values, something like: $if($rsearch(%genre%,\\b\(a|b|c|d\)\\b),do something) to ensure that only whole word matches are made.

1 Like

Sorry, I read and learned for the first time ever about \b, yet I still don’t understand. (Regex as always been my nemesis (Only time I candidly cheated in school…)).

In any case, this means I can simply write the following ?

$if($rsearch(%genre%,\\b\(Rock|Jazz|Folk|Electronic\)\\b),do something)

Thanks again

Yes, but to make the search case-insensitive (recommended), I would use:

$if($rsearch($lower(%genre%),\\b\(rock|jazz|folk|electronic\)\\b),do something)
1 Like