I have an optional title section [ '('%album%[ #%tracknumber%][, %year%]')'] e.g. " (Album #1, 2020)", however, this also produces " (, 2020)" or " ( #2)", which is undesirable.
I am trying to work around it with nested ifs, but I was wondering if there is or could be some chaining function that would achieve this for us.
This is my workaround using ifs:
[ '('
%album%
$IfStrEqual('yy',$if(%album%,'y',)$if(%tracknumber%,'y',),' ')
[#%tracknumber%]
$IfStrEqual('yy',$if($if3(%album%,%tracknumber%),'y',)$if(%year%,'y',),', ')
[%year%]
')']
If it is possible to have a new function, I would be happy to come up with a specification and test cases, albeit it might take weeks before finishing, to make such function really robust and not just fit my usecase.
---
Another (possibly simpler) solution could be a trimming function which would cut off any specified leading and trailing characters, e.g.
$trim2(a1, characterSet) using characters in characterSet as trimming candidates for a.
$trim2(%album%[ #%tracknumber%][, %year%],' ,')
result:
"Album #2, 2020" -> "Album #2, 2020"
" #2, 2020" -> "#2, 2020"
", 2020" -> "2020"