There are several solutions both integrated in TeX and proposed on this side for checking if a substring can be found in a given string (such as IfSubStr, IfStringInList and others).
As for example, \instringTF (as defined here:https://tex.stackexchange.com/a/26873/61517) when used as
\instringTF{graph}{graphs}{We have data}{We do not have data}
gives
We have data
Now, I would like to extend that to several possible substrings, i.e. to a call such as
\instringTF{graph,images}{graphs}{We have data}{We do not have data}
This should still evaluate to
We have data
while
\instringTF{graph,images}{image}{We have data}{We do not have data}
should evaluate to
We do not have data
Are there solutions for that issue, too?
Edit: Peter Grill suggested using a solution from https://tex.stackexchange.com/a/350818/61517. I implemented it, resulting in:
\documentclass[%
reprint,
amsfonts,
floatfix,
amsmath,amssymb,
aps,
pra,
]{revtex4-2}
\usepackage{graphicx}% Include figure files
%\usepackage{dcolumn}% Align table columns on decimal point
%\usepackage{bm}% bold math
\usepackage{todonotes}
%\usepackage{siunitx}
%\usepackage{caption}
\usepackage{letltxmacro}
\usepackage{xstring}
\usepackage[labelformat=simple]{subcaption}
\usepackage{float}
\usepackage{xparse}
\usepackage{substr}
\makeatletter
\renewcommand{\todo}[2][]{\tikzexternaldisable\@todo[#1]{#2}\tikzexternalenable}
\makeatother
\usepackage{hyperref}
\ExplSyntaxOn
\cs_new_protected:Nn \grill_str_multicase:nnTF
{
\seq_set_split:Nnn \l__grill_str_multicase_cases_seq { } { #2 }
\tl_clear:N \l__grill_str_multicase_cases_tl
\int_step_inline:nnnn { 1 } { 2 } { \seq_count:N \l__grill_str_multicase_cases_seq }
{
\seq_set_split:Nnx \l__grill_str_multicase_subcases_seq { }
{ \seq_item:Nn \l__grill_str_multicase_cases_seq { ##1 } }
\seq_map_inline:Nn \l__grill_str_multicase_subcases_seq
{
\tl_put_right:Nx \l__grill_str_multicase_cases_tl
{
{\exp_not:n{####1}}{\seq_item:Nn \l__grill_str_multicase_cases_seq { ##1 + 1}}
}
}
}
\str_case:nVTF { #1 } \l__grill_str_multicase_cases_tl { #3 } { #4 }
}
\cs_generate_variant:Nn \seq_set_split:Nnn { Nnx }
\cs_new_protected:Nn \grill_str_multicase:nn
{
\grill_str_multicase:nnTF { #1 } { #2 } { } { }
}
\cs_new_protected:Nn \grill_str_multicase:nnT
{
\grill_str_multicase:nnTF { #1 } { #2 } { #3 } { }
}
\cs_new_protected:Nn \grill_str_multicase:nnF
{
\grill_str_multicase:nnTF { #1 } { #2 } { } { #3 }
}
\NewDocumentCommand{\IfStringCaseX}{mmo}
{
\IfNoValueTF{#3}
{ \grill_str_multicase:nn { #1 } { #2 } }
{ \grill_str_multicase:nnF { #1 } { #2 } { #3 } }
}
\ExplSyntaxOff
\newcommand{\ConditionalText}[1]{%
\IfStringCaseX{#1}
{
{{images}{graphs}}
{%
We have images/graphs
}
}[{Error: Unknown parameter ``#1'' to ConditionalText}]%
}
\makeatother
\begin{document}
\ConditionalText{images/subx.tikz}
\ConditionalText{images}
\end{document}
Here, the first line containing
\ConditionalText{images/subx.tikz}
produces Unknown parameter, while the second line
\ConditionalText{images}
produces
We have images/graphs
i.e. the proposed solution does not work for my use case.
